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, Possible values: current, min, max, bios,
scaling_current, scaling_min, scaling_max scaling_current, scaling_min, scaling_max
NOTE: This only support Linux with cpufreq. 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 --gpu_shorthand on/off Shorten the output of GPU
--gtk_shorthand on/off Shorten output of gtk theme/icons --gtk_shorthand on/off Shorten output of gtk theme/icons
--gtk2 on/off Enable/Disable gtk2 theme/icons output --gtk2 on/off Enable/Disable gtk2 theme/icons output

29
fetch
View File

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