diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/b-bar | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/.local/bin/b-bar b/.local/bin/b-bar index 8f23563..8641238 100755 --- a/.local/bin/b-bar +++ b/.local/bin/b-bar @@ -1,29 +1,45 @@ #!/bin/sh while true do - h="$(hostname)" + host="$(hostname)" vols="$(b-pavols)" load="$(cat /proc/loadavg | cut -d' ' -f1)" - time="$(date +'%a, %d %b %Y %R %z')" + date="$(date +'%a, %d %b %Y %R %z')" - case $h in + bar="$vols | $load | $date" + + case $host in selene) sens="$(sensors -j w83795g-i2c-*-*)" - nrbr="$(echo $sens | jq -r '.[].temp1.temp1_input')" cpu1="$(echo $sens | jq -r '.[].temp7.temp7_input')" cpu2="$(echo $sens | jq -r '.[].temp8.temp8_input')" - printf "%s %s %s | %s | %s | %s\n" \ - "$nrbr" "$cpu1" "$cpu2" "$vols" "$load" "$time" + # KGPE-D16 northbridge temperature + nrbr="$(echo $sens | jq -r '.[].temp1.temp1_input')" + bar="$cpu1 $cpu2 $nrbr | $bar" + ;; + adelita|anahita) + [ "$host" = "anahita" ] && bdev="sbs_9_000b" || bdev="BAT0" + b0="$(upower -i /org/freedesktop/UPower/devices/battery_$bdev)" + batstat="$(echo "$b0" | awk '/state/{print $NF}')" + if [ "$batstat" = "discharging" ]; then + batstat='-' + elif [ "$batstat" = "charging" ]; then + batstat='+' + fi + batcap="$(echo "$b0" | awk '/percentage/ \ + {sub(/\%$/, "", $NF); \ + print $NF}')" + battime="$(echo "$b0" | awk -F: '/time to (full|empty)/ \ + {sub(/^[ \t]+/, "", $NF); \ + sub(/\ hours?$/, "h", $NF); \ + print $NF}')" + bat="${batcap}$batstat $battime" + bar="$bat | $bar" ;; *) - b0="/sys/class/power_supply/BAT0" - [ "$h" = "anahita" ] && b0="/sys/class/power_supply/sbs-9-000b" - bat="$(cat $b0/capacity)" - # batl="$(cat $b0/capacity_level)" - printf "%s%% | %s | %s | %s\n" \ - "$bat" "$vols" "$load" "$time" ;; esac + printf "$bar\n" sleep 5 done |