battery: migrated threshold to system monitor

This commit is contained in:
Lemmy
2026-02-06 00:03:59 -05:00
parent 7ff6a59c6c
commit 54b6c0263b
10 changed files with 77 additions and 74 deletions
+5 -2
View File
@@ -18,8 +18,8 @@ Singleton {
readonly property bool batteryPluggedIn: isPluggedIn(primaryDevice)
readonly property bool batteryReady: isDeviceReady(primaryDevice)
readonly property bool batteryPresent: isDevicePresent(primaryDevice)
readonly property real warningThreshold: Settings.data.notifications.batteryWarningThreshold
readonly property real criticalThreshold: Settings.data.notifications.batteryCriticalThreshold
readonly property real warningThreshold: Settings.data.systemMonitor.batteryWarningThreshold
readonly property real criticalThreshold: Settings.data.systemMonitor.batteryCriticalThreshold
readonly property string batteryIcon: getIcon(batteryPercentage, batteryCharging, batteryPluggedIn, batteryReady)
readonly property var laptopBatteries: UPower.devices.values.filter(d => d.isLaptopBattery).sort((x, y) => {
@@ -312,6 +312,9 @@ Singleton {
}
function notify(device, level) {
if (!Settings.data.notifications.enableBatteryToast)
return;
var name = getDeviceName(device);
var titleKey = level === "critical" ? "toast.battery.critical" : "toast.battery.low";
var descKey = level === "critical" ? "toast.battery.critical-desc" : "toast.battery.low-desc";