aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2019-09-24 10:53:49 +0300
committerDylan Araps <dylan.araps@gmail.com>2019-09-24 10:53:49 +0300
commitd6bf31f5e75a6bee4ae9349f374b349d8e8eae87 (patch)
tree18a945be59c6967d9e42d074e934f30b5724ae49
parenteb7d543fd837d1548fe57d7547b9a6aa9e0562c9 (diff)
downloadpfetch-d6bf31f5e75a6bee4ae9349f374b349d8e8eae87.tar.gz
docs: update
-rwxr-xr-xpfetch5
1 files changed, 5 insertions, 0 deletions
diff --git a/pfetch b/pfetch
index 7c01240..e5c4585 100755
--- a/pfetch
+++ b/pfetch
@@ -38,16 +38,21 @@ get_kernel() {
}
get_uptime() {
+ # Uptime works by retrieving the data in total seconds and then
+ # converting that data into days, hours and minutes using simple
+ # math.
case $os in
linux)
IFS=. read -r s _ < /proc/uptime
;;
esac
+ # Convert the uptime from seconds into days, hours and minutes.
d=$((s / 60 / 60 / 24))
h=$((s / 60 / 60 % 24))
m=$((s / 60 % 60))
+ # Only append days, hours and minutes if they're non-zero.
[ "$d" = 0 ] || uptime="${uptime}${d}d "
[ "$h" = 0 ] || uptime="${uptime}${h}h "
[ "$m" = 0 ] || uptime="${uptime}${m}m "