mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
battery: auto-apply power profile at startup when DMS managed
fixes #2935
port 1.5
(cherry picked from commit 59c83d19e4)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user