Update battery icon promptly on power changes

This commit is contained in:
David Heinemeier Hansson
2026-06-29 10:49:43 -05:00
parent f67ed326df
commit 924254ed11
5 changed files with 60 additions and 9 deletions
+7 -2
View File
@@ -2,8 +2,13 @@
# omarchy:summary=Returns true if external power is connected.
for ac in /sys/class/power_supply/AC* /sys/class/power_supply/ADP*; do
[[ -r $ac/online && $(cat "$ac/online") == "1" ]] && exit 0
power_supply_path="${OMARCHY_POWER_SUPPLY_PATH:-/sys/class/power_supply}"
for supply in "$power_supply_path"/*; do
[[ -r $supply/online && -r $supply/type ]] || continue
type=$(<"$supply/type")
[[ $type == "Mains" || $type == "USB" ]] || continue
[[ $(<"$supply/online") == "1" ]] && exit 0
done
exit 1