From ac8073fc8156b0e71ea155c3f97757357584067a Mon Sep 17 00:00:00 2001 From: Joshua Fouch <162926985+joshuafouch@users.noreply.github.com> Date: Wed, 29 Oct 2025 05:58:06 -0400 Subject: [PATCH] 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 --- bin/omarchy-battery-monitor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/omarchy-battery-monitor b/bin/omarchy-battery-monitor index 20d6a1e1..84c42974 100755 --- a/bin/omarchy-battery-monitor +++ b/bin/omarchy-battery-monitor @@ -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