dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit 48d3ee14093e9069290e3bd2737a25ede2a4fe2b
parent 4470ed0e0b7b2bb256a90dad7987248be068e768
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 25 Apr 2021 10:51:03 +0100

.s/d/bat: use acpi(1)

Diffstat:
M.scripts/dwmblocks/bat | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/.scripts/dwmblocks/bat b/.scripts/dwmblocks/bat @@ -1,15 +1,12 @@ #!/bin/bash -total=0 -charge=0 -for b in $(find /sys/class/power_supply -name "BAT*") -do - total=$(($total+100)) - read cap < $b/capacity - charge=$(($charge+$cap)) - grep -i 'charg' < $b/status >/dev/null && charging='y' - grep -i 'discharg' < $b/status >/dev/null && discharging='y' -done +case "$(acpi | awk '{print $3}' | tr -d ',')" in + "Charging") charging=y ;; + "Discharging") discharging=y ;; +esac + +total=100 +charge=$(acpi | awk '{print $4}' | tr -d ',%') num=$(echo "scale=2; ($charge/$total)*21" | bc | sed 's~\..*$~~') ind="^c#aa6600^?" [ "$charging" = "y" ] && ind="^c#00aa00^+"