aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2020-03-09 22:57:10 +0200
committerDylan Araps <dylan.araps@gmail.com>2020-03-09 22:57:10 +0200
commit39f767e45bc8e81609a67157bdb46c5819be345f (patch)
treed89b4cdba5ab599f7e134c93854ef5462ebd10ad
parentb2aac93208b8a93edaff96f26b8dc6c4bfb0af4d (diff)
downloadpfetch-39f767e45bc8e81609a67157bdb46c5819be345f.tar.gz
irix: Uptime support.
-rwxr-xr-xpfetch17
1 files changed, 16 insertions, 1 deletions
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