Updated uptime display so it works when no days are displayed

This commit is contained in:
Lucien Cartier-Tilet 2020-04-09 12:59:03 +02:00
parent fbba2d170a
commit 97b5e068e5
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -130,18 +130,12 @@
set -l ruler (string repeat -n $ruler_length "=")
set -l osname (cat /etc/os-release | grep -i pretty_name | sed 's/.*"\(.*\)".*/\1/')
set -l uptime (uptime | awk '{print $1}' | string split ':')
set -l uptime_days (uptime | awk '{print $3}')
set -l uptime (uptime | sed 's/\(.*\):\(.*\):\(.*\) up.*/\1 hours \2 minutes/' | sed 's/ *\(.*\)/\1/')
set -l root (df -Ph | grep -E "/\$")
set -l root_p (echo $root | awk '{print $5}' | tr -d '%')
set -l root_used (echo $root | awk '{print $3}')
set -l root_total (echo $root | awk '{print $2}')
set -l home (df -Ph | grep -E "/home\$")
set -l home_p (echo $home | awk '{print $5}' | tr -d '%')
set -l home_used (echo $home | awk '{print $3}')
set -l home_total (echo $home | awk '{print $2}')
set -l ram (free -tm | grep Mem)
set -l ram_total (echo $ram | awk '{print $2}')
@ -160,10 +154,19 @@
echo $ruler
printf "OS......: %-30sKernel: %s %s\n" $osname (uname -s) (uname -r)
printf "Hostname: %-30sUptime: %d days, %d hours, %d minutes\n" (hostname) $uptime_days $uptime[1] $uptime[2]
printf "Ethernet: %-41sWifi: %s\n" $ethernet $wifi
printf "Hostname: %-30sUptime: %s\n" (hostname) $uptime
printf "Ethernet: %-41sWifi..: %s\n" $ethernet $wifi
printf "Disks...: %-5s %s %6s / %6s (%2d%%)\n" "/" (display_slider $root_p 100) $root_used $root_total $root_p
printf " %-5s %s %6s / %6s (%2d%%)\n" "/home" (display_slider $home_p 100) $home_used $home_total $home_p
# loop other mountpoints
for mp in (df -Ph 2> /dev/null | egrep "sd|tank" | egrep -v "boot|/\$")
set -l mp_p (echo $mp | awk '{print $5}' | tr -d '%')
set -l mp_used (echo $mp | awk '{print $3}')
set -l mp_total (echo $mp | awk '{print $2}')
set -l mp_name (echo $mp | awk '{print $6}')
printf " %-5s %s %6s / %6s (%2d%%)\n" $mp_name (display_slider $mp_p 100) $mp_used $mp_total $mp_p
end
printf "Ram.....: %s %5dM / %5dM (%2d%%)\n" (display_slider $ram_used $ram_total) $ram_used $ram_total $ram_p
printf "Swap....: %s %5dM / %5dM (%2d%%)\n" (display_slider $swap_used $swap_total) $swap_used $swap_total $swap_p
echo $ruler