Skip to content

Let idle screensaver and lock timings be disabled - #9170

Open
voglster wants to merge 2 commits into
omacom:quattrofrom
voglster:idle-disable-timings
Open

voglster wants to merge 2 commits into
omacom:quattrofrom
voglster:idle-disable-timings

Conversation

@voglster

@voglster voglster commented Aug 30, 2026 •

Copy link
Copy Markdown

Closes #7178
Closes #7506

The problem

idle.screensaver and idle.lock in ~/.config/omarchy/shell.json have no way to say "off", and the values that look like off do the opposite. The parser is secondsFromConfig() in shell/plugins/services/idle/IdleModel.js:

var n = Number(value)
if (!isFinite(n) || n < 0) return fallback
return Math.floor(n)

Number(null), Number(false) and Number("") are all 0, and a 0 timing means fire the moment the session goes idle. Behaviour on quattro before this PR:

config value result why it matters
null 0 → fires immediately Number(null) === 0
false 0 → fires immediately Number(false) === 0
"" 0 → fires immediately Number("") === 0
-1 300 (silent default) looks like "off", silently isn't
"off" 300 (silent default) NaN → fallback
missing 300 (default) correct
999999999 returned as-is overflows the Timer int

So the three most intuitive spellings of "off" lock the screen instantly, and the next two silently keep the default — the user thinks it worked until they get locked out mid-task. Both timings share the parser, so "screensaver": null launches the screensaver instantly too.

The overflow is separate: lockDelaySeconds * 1000 feeds a QML Timer.interval, a signed 32-bit millisecond count (max 2147483647 ms ≈ 24.8 days). Anything above that wraps and can fire immediately — again the opposite of intent.

Real case that surfaced it: a stationary desktop that should never idle-lock, but still needs the screensaver and monitor blanking for burn-in. The only workaround today is "lock": 604800 — 7 days, picked to stay under the 32-bit ceiling.

The change

Distinguish unset from explicitly disabled:

  • null, false, "off", "never" (also "none", "no", "disabled"), and negative numbers → disabled, via a DISABLED_SECONDS = -1 sentinel
  • missing, undefined, true, "", and unparseable strings → existing default, unchanged
  • 0 → still 0, still fires immediately — deliberately left alone, since changing it would be a behaviour change
  • everything else → clamped to MAX_SECONDS = 2147483

A disabled timing is skipped when the idle cycle starts rather than pushed out to a huge interval, so its Timer is never started at all. firstIdleTimeout() arbitrates which timing arms the IdleMonitor, ignoring disabled ones, and the monitor itself is disabled when both are off.

"lock": false now does what it reads as: screensaver and monitor blanking keep working, the session never locks.

Judgement calls

  • "" falls back to the default rather than disabling. It's listed above as one of the "looks like off" values, but an empty string reads more like unset than a deliberate choice, and defaulting is the conservative side of a security-relevant decision — a stray empty value shouldn't silently stop a laptop locking. Documented as unset.
  • 0 left as-is. It's a valid, if unusual, "lock immediately" and some config could rely on it. Changing it would be the behaviour change this PR is trying to avoid.
  • Clamp rather than reject oversized values, so the 7-day workaround above keeps working instead of breaking on upgrade.
  • enabled in idle status still means stay-awake. I added separate screensaverConfigured / lockConfigured booleans rather than overloading it, so omarchy-debug-idle and the runtime smoke test's .enabled | type == "boolean" check are unaffected. The numeric screensaver / lock fields keep their type and report -1 when disabled.

No behaviour change for any config that works today.

Testing

test/shell.d/idle-test.sh covers the whole table at the parser level — each disabled spelling, the unset fallbacks, 0 staying immediate, the clamp, and firstIdleTimeout() including the both-disabled case. ./test/cli passes.

test/acceptance.d/idle-test.sh is new and covers the config surface on a real desktop. I ran it in the disposable VM (omarchy-iso-test against the published omarchy-4.0.1.iso, which is the version this was reported from), with local shell/ synced in:

ok - a lock disabled with false is reported as unconfigured
ok - a lock disabled with false reports the disabled sentinel
ok - a lock disabled with false leaves the screensaver configured
ok - a lock disabled with null is reported as unconfigured
ok - a lock disabled with null reports the disabled sentinel
ok - a lock disabled with null leaves the screensaver configured
ok - a lock disabled with "off" is reported as unconfigured
ok - a lock disabled with "off" reports the disabled sentinel
ok - a lock disabled with "off" leaves the screensaver configured
ok - an oversized lock clamps to the timer ceiling
ok - an omitted lock keeps the default timing
ok - an omitted lock stays configured

Reverting just IdleModel.js and Service.qml to their quattro versions in that same VM fails the test on its first assertion, and reproduces the bug on a real installed system — "lock": false yields:

{"lock": 0, "lockDelay": 0}

lockDelay: 0 is lockSystem("lock-timeout-immediate") the moment the session goes idle.

What the acceptance test does not cover

The idle-cycle assertions — screensaver launches, lock timer never arms, session stays unlocked across a real idle transition — skip in that VM, because the shell's IdleMonitor never reports idle there. That is pre-existing and unrelated to this change: with plain {"screensaver": 2, "lock": 300} and no disabled value anywhere, the shell still never goes idle in the guest, while a standalone Quickshell IdleMonitor with the same 2s timeout idles immediately in the same session. So the test skips rather than failing for a reason that has nothing to do with the timings, and those assertions will run on a machine whose session does idle. Worth a second pair of eyes from someone who can reproduce a real idle transition.

Number(null), Number(false) and Number("") are all 0, so the three most
intuitive spellings of "off" made the screensaver or the lock fire the
instant the session went idle. -1 and "off" fell back to the default
instead, so a user who tried to turn locking off silently kept it.

Distinguish unset from explicitly disabled: null, false, "off"/"never"
and negative numbers now disable a timing, an omitted or unparseable
value still falls back to its default, and 0 still fires immediately.
The disabled timing is skipped when the idle cycle starts rather than
being pushed out to a huge interval, and the idle monitor only arms at
timings that are still enabled.

Also clamp timings to 2147483 seconds. Timer.interval is a signed 32-bit
millisecond count, so larger values wrapped and fired immediately -- the
opposite of what a long timeout asks for.
Asserts the config surface against a real installed desktop: each spelling
of "off" reports the disabled sentinel and leaves the screensaver alone, an
oversized timing clamps to the timer ceiling, and an omitted one still
falls back to its default.

The idle-cycle assertions need the compositor to actually report idle.
Headless VMs do not, so they skip rather than fail for a reason unrelated
to the timings.
@voglster

voglster commented Sep 3, 2026

Copy link
Copy Markdown
Author

Heads up on an overlap I should surface rather than leave for a reviewer to find.

#7578 (opened Aug 20) already fixes the int32 overflow behind #7506, and it got there first. I only came across it today while reading through what else referenced #7506. This PR reached the same clamp independently — the disable work needed the same ceiling to be safe, so it fell out of the change rather than being the goal of it.

We landed on the same line in secondsFromConfig, with the same constant and the same reasoning for clamping instead of falling back to the default (a huge number means "never", and dropping to the 5 minute default would lock the user out):

return Math.min(Math.floor(n), 2147483)

I've left Closes #7506 on this PR because the fix genuinely is in here, but I'm not trying to claim that ground. Either sequencing works for me:

Maintainers' call entirely.

One thing worth keeping whichever way it goes: #7578 includes a test asserting that both timeouts actually reach the timers through secondsFromConfig, which guards against someone later reading a timeout straight off idleConfig and bringing the 1 ms timer storm back. This PR doesn't have that assertion and it's a good one.

@MBemera

MBemera commented Sep 9, 2026

Copy link
Copy Markdown

@voglster thanks for the comment mentioning my previous PR. Appreciated the acknowledgement and well written. Thanks again. -MB

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Following the merge of #12538, Zero now disables each action independently, settling the disable-value case. This PR also fixes the actual timer overflow reported in #7506, which remains unfixed. Leaving it open for that remainder; drop the superseded disable semantics and compare the overflow portion with #7578.

Scope checked by GPT-6 in Codex and Codex Medium against the discussion and landed change; review independence is not guaranteed. No tests were rerun for this cleanup.

Omabot on behalf of DHH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

3 participants