IdleInhibitor: initialize at startup, remove persistent setting (#505)

This commit is contained in:
lysec
2025-10-17 13:33:31 +02:00
parent 371ddbc776
commit eae2bf1476
4 changed files with 5 additions and 14 deletions

View File

@@ -207,7 +207,6 @@
"fontFixed": "DejaVu Sans Mono",
"fontDefaultScale": 1,
"fontFixedScale": 1,
"idleInhibitorEnabled": false,
"tooltipsEnabled": true
},
"brightness": {

View File

@@ -342,7 +342,6 @@ Singleton {
property string fontFixed: "DejaVu Sans Mono"
property real fontDefaultScale: 1.0
property real fontFixedScale: 1.0
property bool idleInhibitorEnabled: false
property bool tooltipsEnabled: true
}

View File

@@ -16,15 +16,9 @@ Singleton {
// Different inhibitor strategies
property string strategy: "systemd" // "systemd", "wayland", or "auto"
Component.onCompleted: {
Logger.i("IdleInhibitor", "Service started")
function init() {
Logger.d("IdleInhibitor", "Service started")
detectStrategy()
// Restore previous state from settings
if (Settings.data.ui.idleInhibitorEnabled) {
addInhibitor("manual", "Restored from previous session")
Logger.d("IdleInhibitor", "Restored previous manual inhibition state")
}
}
// Auto-detect the best strategy
@@ -162,15 +156,13 @@ Singleton {
function manualToggle() {
if (activeInhibitors.includes("manual")) {
removeInhibitor("manual")
Settings.data.ui.idleInhibitorEnabled = false
ToastService.showNotice(I18n.tr("tooltips.keep-awake"), I18n.tr("toast.keep-awake.disabled"))
Logger.i("IdleInhibitor", "Manual inhibition disabled and saved to settings")
Logger.i("IdleInhibitor", "Manual inhibition disabled")
return false
} else {
addInhibitor("manual", "Manually activated by user")
Settings.data.ui.idleInhibitorEnabled = true
ToastService.showNotice(I18n.tr("tooltips.keep-awake"), I18n.tr("toast.keep-awake.enabled"))
Logger.i("IdleInhibitor", "Manual inhibition enabled and saved to settings")
Logger.i("IdleInhibitor", "Manual inhibition enabled (will reset on next session)")
return true
}
}

View File

@@ -90,6 +90,7 @@ ShellRoot {
HooksService.init()
BluetoothService.init()
BatteryService.init()
IdleInhibitorService.init()
}
Background {}