From 39f767e45bc8e81609a67157bdb46c5819be345f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 22:57:10 +0200 Subject: [PATCH] irix: Uptime support. --- pfetch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 69b08b7..c7dbd09 100755 --- a/pfetch +++ b/pfetch @@ -338,7 +338,22 @@ get_uptime() { ;; IRIX*) - # TODO + # Grab the uptime in a pretty format. Usually, + # 00:00:00 from the 'ps' command. + t=$(LC_ALL=POSIX ps -o etime= -p 1) + + # Split the pretty output into days or hours + # based on the uptime. + case $t in + *-*) d=${t%%-*} t=${t#*-} ;; + *:*:*) h=${t%%:*} t=${t#*:} ;; + esac + + h=${h#0} t=${t#0} + + # Convert the split pretty fields back into + # seconds so we may re-convert them to our format. + s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:})) ;; esac