diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2020-03-09 22:57:10 +0200 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2020-03-09 22:57:10 +0200 |
| commit | 39f767e45bc8e81609a67157bdb46c5819be345f (patch) | |
| tree | d89b4cdba5ab599f7e134c93854ef5462ebd10ad | |
| parent | b2aac93208b8a93edaff96f26b8dc6c4bfb0af4d (diff) | |
| download | pfetch-39f767e45bc8e81609a67157bdb46c5819be345f.tar.gz | |
irix: Uptime support.
| -rwxr-xr-x | pfetch | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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 |
