From e85a899be09cb9928ea48498791a22ede1e8ade2 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 31 May 2025 22:32:18 +0200 Subject: [PATCH] battery: fix charging warning when low -> plug -> unplug --- .config/quickshell/services/Battery.qml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.config/quickshell/services/Battery.qml b/.config/quickshell/services/Battery.qml index d31c4ec0..c71cc8c7 100644 --- a/.config/quickshell/services/Battery.qml +++ b/.config/quickshell/services/Battery.qml @@ -17,11 +17,14 @@ Singleton { property bool isCritical: percentage <= ConfigOptions.battery.critical / 100 property bool isSuspending: percentage <= ConfigOptions.battery.suspend / 100 - onIsLowChanged: { - if (available && isLow) Hyprland.dispatch(`exec notify-send "Low battery" "Consider plugging in your device" -u critical -a "Shell"`) + property bool isLowAndNotCharging: isLow && !isCharging + property bool isCriticalAndNotCharging: isCritical && !isCharging + + onIsLowAndNotChargingChanged: { + if (available && isLowAndNotCharging) Hyprland.dispatch(`exec notify-send "Low battery" "Consider plugging in your device" -u critical -a "Shell"`) } - onIsCriticalChanged: { - if (available && isCritical) Hyprland.dispatch(`exec notify-send "Critically low battery" "🙏 I ask for pleas charge\nAutomatic suspend triggers at ${ConfigOptions.battery.suspend}%" -u critical -a "Shell"`) + onIsCriticalAndNotChargingChanged: { + if (available && isCriticalAndNotCharging) Hyprland.dispatch(`exec notify-send "Critically low battery" "🙏 I ask for pleas charge\nAutomatic suspend triggers at ${ConfigOptions.battery.suspend}%" -u critical -a "Shell"`) } }