cfg/.config/i3blocks/uptime
Knut Ahlers b2ac615dfb
Improve display of uptime
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-06-25 16:25:31 +02:00

22 lines
385 B
Bash
Executable file

#!/usr/bin/env zsh
up_secs=$(cut -d ' ' -f 1 </proc/uptime | cut -d . -f 1)
num=0
suffix=d
if [ $up_secs -gt 86400 ]; then
num=$((up_secs / 86400.0))
suffix=d
elif [ $up_secs -gt 3600 ]; then
num=$((up_secs / 3600.0))
suffix=h
elif [ $up_secs -gt 60 ]; then
num=$((up_secs / 60.0))
suffix=m
else
num=${up_secs}
suffix=s
fi
printf "\uf2f2 %.0f%s\n" ${num} ${suffix}