Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions quickshell/Common/SessionData.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions quickshell/Common/settings/SessionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var SPEC = {
isLightMode: { def: false },
doNotDisturb: { def: false },
doNotDisturbUntil: { def: 0 },
idleInhibited: { def: false },
terminalOverride: { def: "" },

wallpaperPath: { def: "" },
Expand Down
25 changes: 25 additions & 0 deletions quickshell/Services/SessionService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -488,17 +488,42 @@ 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();
}

function disableIdleInhibit() {
if (!idleInhibited)
return;
idleInhibited = false;
SessionData.setIdleInhibited(false);
inhibitorChanged();
}

Expand Down
Loading