From 9b6e7782dce45cc4f1ca113d575a8d3d40d61ce9 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Apr 2016 10:12:46 +1000 Subject: [PATCH] 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