From 7258819c1ff30fdae052fc353c308d31aec4326f Mon Sep 17 00:00:00 2001 From: davfsa Date: Tue, 24 Dec 2024 12:03:46 +0100 Subject: [PATCH] Make low battery thresholds inclusive and support multiple $POWER_LEVEL replacements (#611) Co-authored-by: Jas Singh --- src/lib/behaviors/batteryWarning.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/behaviors/batteryWarning.ts b/src/lib/behaviors/batteryWarning.ts index 09c51a8..038398a 100644 --- a/src/lib/behaviors/batteryWarning.ts +++ b/src/lib/behaviors/batteryWarning.ts @@ -29,19 +29,19 @@ export function warnOnLowBattery(): void { // To avoid double notifications, we check each of the thresholds and set the correct `sentNotification`, but then // combine them into one notification only let sendNotification = false; - if (!sentLowNotification && batteryPercentage < lowThreshold) { + if (!sentLowNotification && batteryPercentage <= lowThreshold) { sentLowNotification = true; sendNotification = true; } - if (!sentHalfLowNotification && batteryPercentage < lowThreshold / 2) { + if (!sentHalfLowNotification && batteryPercentage <= lowThreshold / 2) { sentHalfLowNotification = true; sendNotification = true; } if (sendNotification) { Notify({ - summary: lowBatteryNotificationTitle.get().replace('$POWER_LEVEL', batteryPercentage.toString()), - body: lowBatteryNotificationText.get().replace('$POWER_LEVEL', batteryPercentage.toString()), + summary: lowBatteryNotificationTitle.get().replaceAll('$POWER_LEVEL', batteryPercentage.toString()), + body: lowBatteryNotificationText.get().replaceAll('$POWER_LEVEL', batteryPercentage.toString()), iconName: icons.ui.warning, urgency: 'critical', });