diff options
author | Amin Bandali <bandali@kelar.org> | 2024-08-31 00:54:31 -0400 |
---|---|---|
committer | Amin Bandali <bandali@kelar.org> | 2024-08-31 00:56:58 -0400 |
commit | 8052f35b9b29d9d3624be1c161ad4f41ee26a533 (patch) | |
tree | 75efa428582bee68b4033880b9af912521293d72 /.local/bin/b-bar | |
parent | 63879fc37e2b7e7f4d6069dfc287a85ee758b1f8 (diff) | |
download | configs-8052f35b9b29d9d3624be1c161ad4f41ee26a533.tar.gz configs-8052f35b9b29d9d3624be1c161ad4f41ee26a533.tar.xz configs-8052f35b9b29d9d3624be1c161ad4f41ee26a533.zip |
Rewrite b-bar to use upower for battery info
Diffstat (limited to '.local/bin/b-bar')
-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 |