From b9b163bbda84b58edd8e28ecdfa411adfa6888a2 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 25 Aug 2023 18:13:11 +0300 Subject: eww: Correctly detect ‘status == Charging’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/eww/scripts/battery | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to '.config') 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 -- cgit v1.2.3