Fix: Low Battery notification returning empty value on reboot (#2949)

* Fix: Low Battery notification returning empty value on reboot

* Simplify the check

* Double paste

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
Joshua Fouch
2025-10-29 05:58:06 -04:00
committed by GitHub
parent 7770f49c1a
commit ac8073fc81

View File

@@ -11,11 +11,13 @@ send_notification() {
notify-send -u critical "󱐋 Time to recharge!" "Battery is down to ${1}%" -i battery-caution -t 30000
}
if [[ $BATTERY_STATE == "discharging" && $BATTERY_LEVEL -le $BATTERY_THRESHOLD ]]; then
if [[ ! -f $NOTIFICATION_FLAG ]]; then
send_notification $BATTERY_LEVEL
touch $NOTIFICATION_FLAG
if [[ -n "$BATTERY_LEVEL" && "$BATTERY_LEVEL" =~ ^[0-9]+$ ]]; then
if [[ $BATTERY_STATE == "discharging" && $BATTERY_LEVEL -le $BATTERY_THRESHOLD ]]; then
if [[ ! -f $NOTIFICATION_FLAG ]]; then
send_notification $BATTERY_LEVEL
touch $NOTIFICATION_FLAG
fi
else
rm -f $NOTIFICATION_FLAG
fi
else
rm -f $NOTIFICATION_FLAG
fi