Merge pull request #534 from dylanaraps/uptime
Uptime: Rewrite part of uptime
This commit is contained in:
commit
b3f7479e8e
2 changed files with 15 additions and 17 deletions
|
@ -92,7 +92,7 @@ os_arch="on"
|
||||||
|
|
||||||
# Shorten the output of the uptime function
|
# Shorten the output of the uptime function
|
||||||
#
|
#
|
||||||
# Default: 'off'
|
# Default: 'on'
|
||||||
# Values: 'on', 'off', 'tiny'
|
# Values: 'on', 'off', 'tiny'
|
||||||
# Flag: --uptime_shorthand
|
# Flag: --uptime_shorthand
|
||||||
#
|
#
|
||||||
|
@ -100,7 +100,7 @@ os_arch="on"
|
||||||
# on: '2 days, 10 hours, 3 mins'
|
# on: '2 days, 10 hours, 3 mins'
|
||||||
# off: '2 days, 10 hours, 3 minutes'
|
# off: '2 days, 10 hours, 3 minutes'
|
||||||
# tiny: '2d 10h 3m'
|
# tiny: '2d 10h 3m'
|
||||||
uptime_shorthand="off"
|
uptime_shorthand="on"
|
||||||
|
|
||||||
|
|
||||||
# Shell
|
# Shell
|
||||||
|
|
28
neofetch
28
neofetch
|
@ -329,24 +329,22 @@ get_uptime() {
|
||||||
|
|
||||||
days="$((seconds / 60 / 60 / 24)) days"
|
days="$((seconds / 60 / 60 / 24)) days"
|
||||||
hours="$((seconds / 60 / 60 % 24)) hours"
|
hours="$((seconds / 60 / 60 % 24)) hours"
|
||||||
minutes="$((seconds / 60 % 60)) minutes"
|
mins="$((seconds / 60 % 60)) minutes"
|
||||||
|
|
||||||
case "$days" in
|
# Format the days, hours and minutes.
|
||||||
"0 days") unset days ;;
|
strip_date() {
|
||||||
"1 days") days="${days/s}" ;;
|
case "$1" in
|
||||||
esac
|
"0 "*) unset "${1/* }" ;;
|
||||||
|
"1 "*) printf "%s" "${1/s}" ;;
|
||||||
|
*) printf "%s" "$1" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
case "$hours" in
|
days="$(strip_date "$days")"
|
||||||
"0 hours") unset hours ;;
|
hours="$(strip_date "$hours")"
|
||||||
"1 hours") hours="${hours/s}" ;;
|
mins="$(strip_date "$mins")"
|
||||||
esac
|
|
||||||
|
|
||||||
case "$minutes" in
|
uptime="${days:+$days, }${hours:+$hours, }${mins}"
|
||||||
"0 minutes") unset minutes ;;
|
|
||||||
"1 minutes") minutes="${minutes/s}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
uptime="${days:+$days, }${hours:+$hours, }${minutes}"
|
|
||||||
uptime="${uptime%', '}"
|
uptime="${uptime%', '}"
|
||||||
uptime="${uptime:-${seconds} seconds}"
|
uptime="${uptime:-${seconds} seconds}"
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue