diff --git a/quickshell/Common/SessionData.qml b/quickshell/Common/SessionData.qml index 856be9f94..8082a1415 100644 --- a/quickshell/Common/SessionData.qml +++ b/quickshell/Common/SessionData.qml @@ -34,6 +34,7 @@ Singleton { property bool isLightMode: false property bool doNotDisturb: false property real doNotDisturbUntil: 0 + property bool idleInhibited: false property string terminalOverride: "" property bool isSwitchingMode: false property bool suppressOSD: true @@ -626,6 +627,14 @@ Singleton { saveSettings(); } + function setIdleInhibited(enabled) { + const next = !!enabled; + if (idleInhibited === next) + return; + idleInhibited = next; + saveSettings(); + } + function setDoNotDisturbUntilTimestamp(timestampMs) { const target = Number(timestampMs) || 0; if (target <= Date.now()) { diff --git a/quickshell/Common/settings/SessionSpec.js b/quickshell/Common/settings/SessionSpec.js index 03136f134..fb3ddf8c3 100644 --- a/quickshell/Common/settings/SessionSpec.js +++ b/quickshell/Common/settings/SessionSpec.js @@ -4,6 +4,7 @@ var SPEC = { isLightMode: { def: false }, doNotDisturb: { def: false }, doNotDisturbUntil: { def: 0 }, + idleInhibited: { def: false }, terminalOverride: { def: "" }, wallpaperPath: { def: "" }, diff --git a/quickshell/Services/SessionService.qml b/quickshell/Services/SessionService.qml index 417b601c5..8b845875d 100644 --- a/quickshell/Services/SessionService.qml +++ b/quickshell/Services/SessionService.qml @@ -488,10 +488,34 @@ Singleton { // * Idle Inhibitor signal inhibitorChanged + // The inhibitor is a state the user turns on explicitly, so it is persisted in the session + // like the other Control Center toggles (doNotDisturb, nightModeEnabled, ...). Without this + // it lived only in memory and every shell restart silently cleared it. + // + // Both entry points are needed because the two singletons are lazily created and the order is + // not fixed: onLoaded covers "service first, session file read later", the restore below + // covers "session already loaded by the time the service is instantiated". enableIdleInhibit + // is idempotent, so whichever runs second does nothing. + function _restoreIdleInhibit() { + if (SessionData.idleInhibited && !idleInhibited) + enableIdleInhibit(); + } + + Connections { + target: SessionData + + function onLoaded() { + root._restoreIdleInhibit(); + } + } + + Component.onCompleted: _restoreIdleInhibit() + function enableIdleInhibit() { if (idleInhibited) return; idleInhibited = true; + SessionData.setIdleInhibited(true); inhibitorChanged(); } @@ -499,6 +523,7 @@ Singleton { if (!idleInhibited) return; idleInhibited = false; + SessionData.setIdleInhibited(false); inhibitorChanged(); }