Added new uptime_shorthand option called 'tiny'. It makes the output of uptime as small as possible eg: '1d 2h 35m'

This commit is contained in:
Dylan 2016-01-26 12:16:39 +11:00
parent 43416ebad5
commit 04280a688e
2 changed files with 23 additions and 8 deletions

View file

@ -176,7 +176,7 @@ alias fetch2="fetch \
Possible values: current, min, max, bios,
scaling_current, scaling_min, scaling_max
NOTE: This only support Linux with cpufreq.
--uptime_shorthand Shorten the output of uptime
--uptime_shorthand Shorten the output of uptime (tiny, on, off)
--gpu_shorthand on/off Shorten the output of GPU
--gtk_shorthand on/off Shorten output of gtk theme/icons
--gtk2 on/off Enable/Disable gtk2 theme/icons output

29
fetch
View file

@ -102,7 +102,7 @@ gpu_shorthand="off"
# Uptime
# Shorten the output of the uptime function
# --uptime_shorthand on/off
# --uptime_shorthand tiny, on, off
uptime_shorthand="off"
@ -446,11 +446,26 @@ getuptime () {
esac
if [ "$uptime_shorthand" == "on" ]; then
uptime=${uptime/up/}
uptime=${uptime/minutes/mins}
uptime=${uptime# }
fi
case "$uptime_shorthand" in
"on")
uptime=${uptime/up/}
uptime=${uptime/minutes/mins}
uptime=${uptime/minute/min}
uptime=${uptime# }
;;
"tiny")
uptime=${uptime/'up'/}
uptime=${uptime/' days'/'d'}
uptime=${uptime/' day'/'d'}
uptime=${uptime/' hours'/'h'}
uptime=${uptime/' hour'/'h'}
uptime=${uptime/' minutes'/'m'}
uptime=${uptime/' minute'/'m'}
uptime=${uptime/','}
uptime=${uptime# }
;;
esac
}
# Get package count
@ -1284,7 +1299,7 @@ usage () { cat << EOF
Possible values: current, min, max, bios,
scaling_current, scaling_min, scaling_max
NOTE: This only support Linux with cpufreq.
--uptime_shorthand Shorten the output of uptime
--uptime_shorthand Shorten the output of uptime (tiny, on, off)
--gpu_shorthand on/off Shorten the output of GPU
--gtk_shorthand on/off Shorten output of gtk theme/icons
--gtk2 on/off Enable/Disable gtk2 theme/icons output