From 59c83d19e4cc0e349c8169d035886b1106251570 Mon Sep 17 00:00:00 2001 From: bbedward Date: Sun, 26 Jul 2026 15:27:07 -0400 Subject: [PATCH] battery: auto-apply power profile at startup when DMS managed fixes #2935 port 1.5 --- quickshell/Services/BatteryService.qml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/quickshell/Services/BatteryService.qml b/quickshell/Services/BatteryService.qml index e9763a66e..24116920b 100644 --- a/quickshell/Services/BatteryService.qml +++ b/quickshell/Services/BatteryService.qml @@ -17,7 +17,22 @@ Singleton { interval: 500 repeat: false running: true - onTriggered: root.suppressSound = false + onTriggered: { + root.suppressSound = false; + root.applyPowerProfile(); + } + } + + function applyPowerProfile() { + if (!batteryAvailable) + return; + const profileValue = isPluggedIn ? SettingsData.acProfileName : SettingsData.batteryProfileName; + if (profileValue === "") + return; + const targetProfile = parseInt(profileValue); + if (isNaN(targetProfile) || PowerProfiles.profile === targetProfile) + return; + PowerProfiles.profile = targetProfile; } readonly property string preferredBatteryOverride: Quickshell.env("DMS_PREFERRED_BATTERY") @@ -206,14 +221,7 @@ Singleton { } } - const profileValue = BatteryService.isPluggedIn ? SettingsData.acProfileName : SettingsData.batteryProfileName; - - if (profileValue !== "") { - const targetProfile = parseInt(profileValue); - if (!isNaN(targetProfile) && PowerProfiles.profile !== targetProfile) { - PowerProfiles.profile = targetProfile; - } - } + applyPowerProfile(); previousPluggedState = isPluggedIn; }