From f8c350cbff79ca19644737052a99971f1a16f4ae Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:42:58 +1000 Subject: [PATCH 01/18] Fix issues with uptime on OSX and BSD --- neofetch | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index 8d7630fc..ef121786 100755 --- a/neofetch +++ b/neofetch @@ -591,22 +591,22 @@ getuptime () { days=$((uptime / 86400)) # Format the output like Linux's "uptime -p" cmd. - if [ "$mins" == 1 ]; then - uptime="$mins minute" - elif [ "$mins" != 0 ]; then + if [ "$mins" != 0 ]; then uptime="$mins minutes" + else + uptime="$mins minute" fi - if [ "$hours" == 1 ]; then - uptime="$hours hour, $uptime" - elif [ "$mins" != 0 ]; then + if [ "$mins" != 0 ]; then uptime="$hours hours, $uptime" + else + uptime="$hours hour, $uptime" fi - if [ "$days" == 1 ]; then - uptime="$days day, $uptime" - elif [ "$days" != 0 ]; then + if [ "$days" != 0 ]; then uptime="$days days, $uptime" + else + uptime="$days day, $uptime" fi uptime="up $uptime" From 0a5e676b7406663fb2e2ec9783461aa36a8dd6c7 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:44:24 +1000 Subject: [PATCH 02/18] Revert fixes --- neofetch | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index ef121786..8d7630fc 100755 --- a/neofetch +++ b/neofetch @@ -591,22 +591,22 @@ getuptime () { days=$((uptime / 86400)) # Format the output like Linux's "uptime -p" cmd. - if [ "$mins" != 0 ]; then - uptime="$mins minutes" - else + if [ "$mins" == 1 ]; then uptime="$mins minute" + elif [ "$mins" != 0 ]; then + uptime="$mins minutes" fi - if [ "$mins" != 0 ]; then - uptime="$hours hours, $uptime" - else + if [ "$hours" == 1 ]; then uptime="$hours hour, $uptime" + elif [ "$mins" != 0 ]; then + uptime="$hours hours, $uptime" fi - if [ "$days" != 0 ]; then - uptime="$days days, $uptime" - else + if [ "$days" == 1 ]; then uptime="$days day, $uptime" + elif [ "$days" != 0 ]; then + uptime="$days days, $uptime" fi uptime="up $uptime" From b193b9e5d58367065311e4116b12db14e606b054 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:46:47 +1000 Subject: [PATCH 03/18] Add verbose output --- neofetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neofetch b/neofetch index 8d7630fc..c7540a53 100755 --- a/neofetch +++ b/neofetch @@ -590,6 +590,10 @@ getuptime () { hours=$((uptime / 3600%24)) days=$((uptime / 86400)) + echo "$mins" + echo "$hours" + echo "$days" + # Format the output like Linux's "uptime -p" cmd. if [ "$mins" == 1 ]; then uptime="$mins minute" From a2712b6333078ec335ada8df1dcade205db578b9 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:52:47 +1000 Subject: [PATCH 04/18] New uptime formatting --- neofetch | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/neofetch b/neofetch index c7540a53..d95393e8 100755 --- a/neofetch +++ b/neofetch @@ -594,26 +594,11 @@ getuptime () { echo "$hours" echo "$days" - # Format the output like Linux's "uptime -p" cmd. - if [ "$mins" == 1 ]; then - uptime="$mins minute" - elif [ "$mins" != 0 ]; then - uptime="$mins minutes" - fi + days="$days days," + hours="$hours hours," + mins="$mins minutes" - if [ "$hours" == 1 ]; then - uptime="$hours hour, $uptime" - elif [ "$mins" != 0 ]; then - uptime="$hours hours, $uptime" - fi - - if [ "$days" == 1 ]; then - uptime="$days day, $uptime" - elif [ "$days" != 0 ]; then - uptime="$days days, $uptime" - fi - - uptime="up $uptime" + uptime="up ${days/0 days,} ${hours/ 0 hours,} ${mins/0 mins}" ;; esac From bef0e37984810735b7cb3cd403de192f7b648cf3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:54:02 +1000 Subject: [PATCH 05/18] Fix error with hours --- neofetch | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/neofetch b/neofetch index d95393e8..b888aed9 100755 --- a/neofetch +++ b/neofetch @@ -590,15 +590,11 @@ getuptime () { hours=$((uptime / 3600%24)) days=$((uptime / 86400)) - echo "$mins" - echo "$hours" - echo "$days" - days="$days days," hours="$hours hours," mins="$mins minutes" - uptime="up ${days/0 days,} ${hours/ 0 hours,} ${mins/0 mins}" + uptime="up ${days/0 days,} ${hours/0 hours,} ${mins/0 mins}" ;; esac From a899ea97c2a24f1b64a996e7ecf396bad106cb31 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:57:22 +1000 Subject: [PATCH 06/18] Uptime formatting --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index b888aed9..5d216f10 100755 --- a/neofetch +++ b/neofetch @@ -594,7 +594,7 @@ getuptime () { hours="$hours hours," mins="$mins minutes" - uptime="up ${days/0 days,} ${hours/0 hours,} ${mins/0 mins}" + uptime="up ${days/0 days,} ${days/1 days/1 day} ${hours/0 hours,} ${hours/1 hours/1 hour} ${mins/0 minutes} ${mins/1 minutes/1 minute}" ;; esac From 382a018fb4ef3cc9bc19886ef7167d9bd393943d Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 09:58:16 +1000 Subject: [PATCH 07/18] Revert fixeS --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 5d216f10..3f26f025 100755 --- a/neofetch +++ b/neofetch @@ -594,7 +594,7 @@ getuptime () { hours="$hours hours," mins="$mins minutes" - uptime="up ${days/0 days,} ${days/1 days/1 day} ${hours/0 hours,} ${hours/1 hours/1 hour} ${mins/0 minutes} ${mins/1 minutes/1 minute}" + uptime="up ${days/0 days,} ${hours/0 hours,} ${mins/0 minutes}" ;; esac From 9871e651483afef6731e280566686dbe0f27974e Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:00:48 +1000 Subject: [PATCH 08/18] Easy way to find start of string --- neofetch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 3f26f025..bcee1b73 100755 --- a/neofetch +++ b/neofetch @@ -590,11 +590,11 @@ getuptime () { hours=$((uptime / 3600%24)) days=$((uptime / 86400)) - days="$days days," - hours="$hours hours," - mins="$mins minutes" + days=" $days days," + hours=" $hours hours," + mins=" $mins minutes" - uptime="up ${days/0 days,} ${hours/0 hours,} ${mins/0 minutes}" + uptime="up${days/ 0 days,}${hours/ 0 hours,}${mins/ 0 minutes}" ;; esac From cec15d9fb2c9bb3846c8747d6bee793e15d9a5a2 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:05:35 +1000 Subject: [PATCH 09/18] Uptime fixes --- neofetch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index bcee1b73..eb7f4b63 100755 --- a/neofetch +++ b/neofetch @@ -594,7 +594,16 @@ getuptime () { hours=" $hours hours," mins=" $mins minutes" - uptime="up${days/ 0 days,}${hours/ 0 hours,}${mins/ 0 minutes}" + days=${days/ 0 days,} + days=${days/ 1 days/ 1 day} + + hours=${hours/ 0 hours,} + hours=${hours/ 1 hours/ 1 hour} + + mins=${mins/ 0 minutes} + mins=${mins/ 1 minutes/ 1 minute} + + uptime="up${days}${hours}${mins}" ;; esac From f1cc911e02aff2281c539591bc15baab9956a618 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:08:56 +1000 Subject: [PATCH 10/18] Fix comma issues --- neofetch | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/neofetch b/neofetch index eb7f4b63..6f0f538f 100755 --- a/neofetch +++ b/neofetch @@ -590,20 +590,20 @@ getuptime () { hours=$((uptime / 3600%24)) days=$((uptime / 86400)) - days=" $days days," - hours=" $hours hours," - mins=" $mins minutes" + days=" $days days" + hours=", $hours hours" + mins=", $mins minutes" - days=${days/ 0 days,} - days=${days/ 1 days/ 1 day} + days=${days/ 0 days} + days=${days/, 1 days/, 1 day} - hours=${hours/ 0 hours,} - hours=${hours/ 1 hours/ 1 hour} + hours=${hours/, 0 hours} + hours=${hours/, 1 hours/, 1 hour} - mins=${mins/ 0 minutes} - mins=${mins/ 1 minutes/ 1 minute} + mins=${mins/, 0 minutes} + mins=${mins/, 1 minutes/, 1 minute} - uptime="up${days}${hours}${mins}" + uptime="up ${days}${hours}${mins}" ;; esac From 9b6e7782dce45cc4f1ca113d575a8d3d40d61ce9 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:12:46 +1000 Subject: [PATCH 11/18] Rewrite uptime --- neofetch | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/neofetch b/neofetch index 6f0f538f..4aef53d9 100755 --- a/neofetch +++ b/neofetch @@ -590,20 +590,25 @@ getuptime () { hours=$((uptime / 3600%24)) days=$((uptime / 86400)) - days=" $days days" - hours=", $hours hours" - mins=", $mins minutes" + case "$mins" in + 1) mins="1 minute" ;; + 0) ;; + *) mins="$mins minutes" ;; + esac - days=${days/ 0 days} - days=${days/, 1 days/, 1 day} + case "$hours" in + 1) hours="1 hour" ;; + 0) ;; + *) hours="$hours hours" ;; + esac - hours=${hours/, 0 hours} - hours=${hours/, 1 hours/, 1 hour} + case "$days" in + 1) days="1 day" ;; + 0) ;; + *) days="$days days" ;; + esac - mins=${mins/, 0 minutes} - mins=${mins/, 1 minutes/, 1 minute} - - uptime="up ${days}${hours}${mins}" + uptime="up $days, $hours, $minutes" ;; esac From 11d80dd284fdc5bb71c0372a2b318419541e30e7 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:13:45 +1000 Subject: [PATCH 12/18] Change mins to minutes --- neofetch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 4aef53d9..219c93e4 100755 --- a/neofetch +++ b/neofetch @@ -586,14 +586,14 @@ getuptime () { uptime=$((now - boot)) # Convert uptime to days/hours/mins - mins=$((uptime / 60%60)) + minutes=$((uptime / 60%60)) hours=$((uptime / 3600%24)) days=$((uptime / 86400)) - case "$mins" in - 1) mins="1 minute" ;; + case "$minutes" in + 1) minutes="1 minute" ;; 0) ;; - *) mins="$mins minutes" ;; + *) minutes="$minutes minutes" ;; esac case "$hours" in From 1c78fb13432a4b4be8d6adf6adeb742740f5053b Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:14:55 +1000 Subject: [PATCH 13/18] Fix issues with 0 --- neofetch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index 219c93e4..97ee532e 100755 --- a/neofetch +++ b/neofetch @@ -592,20 +592,20 @@ getuptime () { case "$minutes" in 1) minutes="1 minute" ;; - 0) ;; + 0) unset minutes ;; *) minutes="$minutes minutes" ;; esac case "$hours" in - 1) hours="1 hour" ;; - 0) ;; - *) hours="$hours hours" ;; + 1) hours="1 hour," ;; + 0) unset hours ;; + *) hours="$hours hours," ;; esac case "$days" in - 1) days="1 day" ;; - 0) ;; - *) days="$days days" ;; + 1) days="1 day," ;; + 0) unset days;; + *) days="$days days," ;; esac uptime="up $days, $hours, $minutes" From ecdc3ff9b45cf2cb82dab071a51891df0fa1157f Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:15:41 +1000 Subject: [PATCH 14/18] Remove commas --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 97ee532e..354ce118 100755 --- a/neofetch +++ b/neofetch @@ -608,7 +608,7 @@ getuptime () { *) days="$days days," ;; esac - uptime="up $days, $hours, $minutes" + uptime="up $days $hours $minutes" ;; esac From 08e8113c8bdde811ca127be057dba44a5c704d96 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:19:09 +1000 Subject: [PATCH 15/18] Better comma hanfling --- neofetch | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 354ce118..e2403dd8 100755 --- a/neofetch +++ b/neofetch @@ -597,17 +597,25 @@ getuptime () { esac case "$hours" in - 1) hours="1 hour," ;; + 1) hours="1 hour" ;; 0) unset hours ;; - *) hours="$hours hours," ;; + *) hours="$hours hours" ;; esac case "$days" in - 1) days="1 day," ;; - 0) unset days;; - *) days="$days days," ;; + 1) days="1 day" ;; + 0) unset days ;; + *) days="$days days" ;; esac + [ ! -z "$hours" ] && \ + [ ! -z "$minutes" ] && \ + hours+="," + + [ ! -z "$days" ] && \ + [ ! -z "$hours" ] && \ + days+="," + uptime="up $days $hours $minutes" ;; esac From d47c12614487898bb50f0dd917c23f9368a52ce4 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:25:46 +1000 Subject: [PATCH 16/18] Cleaner rewrite --- neofetch | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/neofetch b/neofetch index e2403dd8..fe30d400 100755 --- a/neofetch +++ b/neofetch @@ -591,32 +591,24 @@ getuptime () { days=$((uptime / 86400)) case "$minutes" in - 1) minutes="1 minute" ;; + 1) uptime="1 minute" ;; 0) unset minutes ;; - *) minutes="$minutes minutes" ;; + *) uptime="$minutes minutes" ;; esac case "$hours" in - 1) hours="1 hour" ;; + 1) uptime="1 hour, $uptime" ;; 0) unset hours ;; - *) hours="$hours hours" ;; + *) uptime="$hours hours, $uptime" ;; esac case "$days" in - 1) days="1 day" ;; + 1) uptime="1 day, $uptime" ;; 0) unset days ;; - *) days="$days days" ;; + *) uptime="$days days, $uptime" ;; esac - [ ! -z "$hours" ] && \ - [ ! -z "$minutes" ] && \ - hours+="," - - [ ! -z "$days" ] && \ - [ ! -z "$hours" ] && \ - days+="," - - uptime="up $days $hours $minutes" + uptime="up $uptime" ;; esac From 7eaf3f3b4dfc759f06502904dbaa1ab44a561902 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:27:43 +1000 Subject: [PATCH 17/18] Revert back to more reliable function --- neofetch | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index fe30d400..e2403dd8 100755 --- a/neofetch +++ b/neofetch @@ -591,24 +591,32 @@ getuptime () { days=$((uptime / 86400)) case "$minutes" in - 1) uptime="1 minute" ;; + 1) minutes="1 minute" ;; 0) unset minutes ;; - *) uptime="$minutes minutes" ;; + *) minutes="$minutes minutes" ;; esac case "$hours" in - 1) uptime="1 hour, $uptime" ;; + 1) hours="1 hour" ;; 0) unset hours ;; - *) uptime="$hours hours, $uptime" ;; + *) hours="$hours hours" ;; esac case "$days" in - 1) uptime="1 day, $uptime" ;; + 1) days="1 day" ;; 0) unset days ;; - *) uptime="$days days, $uptime" ;; + *) days="$days days" ;; esac - uptime="up $uptime" + [ ! -z "$hours" ] && \ + [ ! -z "$minutes" ] && \ + hours+="," + + [ ! -z "$days" ] && \ + [ ! -z "$hours" ] && \ + days+="," + + uptime="up $days $hours $minutes" ;; esac From 1c9f19fd21117131c6177d38a5ccb5a3e47d7c2a Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:39:07 +1000 Subject: [PATCH 18/18] Fix shorthand uptime --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index e2403dd8..ecafa53b 100755 --- a/neofetch +++ b/neofetch @@ -623,7 +623,7 @@ getuptime () { # Make the output of uptime smaller. case "$uptime_shorthand" in "on") - uptime=${uptime/up} + uptime=${uptime/up } uptime=${uptime/minutes/mins} uptime=${uptime/minute/min} uptime=${uptime/seconds/secs} @@ -631,7 +631,7 @@ getuptime () { ;; "tiny") - uptime=${uptime/up} + uptime=${uptime/up } uptime=${uptime/ days/d} uptime=${uptime/ day/d} uptime=${uptime/ hours/h}