diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-08-25 18:13:11 +0300 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-08-25 18:13:11 +0300 |
commit | b9b163bbda84b58edd8e28ecdfa411adfa6888a2 (patch) | |
tree | 724f9132317fd43466c8d85d196cd73b2842eb2e /.config/eww/scripts | |
parent | 7d7d512a07516c2d3aa09322142d87bdf048b3ca (diff) |
eww: Correctly detect ‘status == Charging’
Diffstat (limited to '.config/eww/scripts')
-rwxr-xr-x | .config/eww/scripts/battery | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/.config/eww/scripts/battery b/.config/eww/scripts/battery index 9905949..071f0e9 100755 --- a/.config/eww/scripts/battery +++ b/.config/eww/scripts/battery @@ -2,31 +2,37 @@ set -e +cd /sys/class/power_supply/BAT1 + awk ' - { - printf "percentage=%d%%\n", $0 + FILENAME == "capacity" { + val = $0 + printf "percentage=%d%%\n", val + } + + FILENAME == "status" { printf "icon=" - if ($1 == "Charging") + if ($0 == "Charging") print "" - else if ($0 >= 90) + else if (val >= 90) print "" - else if ($0 >= 80) + else if (val >= 80) print "" - else if ($0 >= 70) + else if (val >= 70) print "" - else if ($0 >= 60) + else if (val >= 60) print "" - else if ($0 >= 50) + else if (val >= 50) print "" - else if ($0 >= 40) + else if (val >= 40) print "" - else if ($0 >= 30) + else if (val >= 30) print "" - else if ($0 >= 20) + else if (val >= 20) print "" - else if ($0 >= 10) + else if (val >= 10) print "" else print "" - }' /sys/class/power_supply/BAT1/capacity \ + }' capacity status \ | jo |