diff options
author | ZachIR <zachir@librem.one> | 2025-07-30 05:20:44 -0500 |
---|---|---|
committer | ZachIR <zachir@librem.one> | 2025-07-30 05:20:44 -0500 |
commit | eeb54dc363b89436945ece5e7b43a0ff12cc8543 (patch) | |
tree | e11e5101956ddf181b927036417f26e67f1e98c9 | |
parent | 81ec1ff738923a54a285873baa61ccb63ba320ce (diff) |
Add battery script to work around waybar
-rwxr-xr-x | custom-battery | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/custom-battery b/custom-battery new file mode 100755 index 0000000..3f07991 --- /dev/null +++ b/custom-battery @@ -0,0 +1,11 @@ +#!/bin/sh + +percentage="$(cat /sys/class/power_supply/BAT0/capacity)" +class="" +tooltip="$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep 'time to' | sed -E 's/^\s*//;s/\s+/ /g')" +[ "$percentage" -lt "30" ] && class="battery_low" +[ "$percentage" -lt "15" ] && class="battery_crit" +grep -qE '^Charging$' /sys/class/power_supply/BAT0/status && class="battery_charging" + +printf "{\"text\": \"battery\", \"alt\": \"bat\", \"tooltip\": \"$tooltip\", \"class\": \"${class}\", \"percentage\": ${percentage}" +printf "}" |