Skip to content

Prevent screensaver launch during lock transitions - #7132

Closed
mlitwiniuk wants to merge 1 commit into
omacom:quattrofrom
mlitwiniuk:fix/idle-lock-screensaver-race
Closed

mlitwiniuk wants to merge 1 commit into
omacom:quattrofrom
mlitwiniuk:fix/idle-lock-screensaver-race

Conversation

@mlitwiniuk

Copy link
Copy Markdown

Fixes #6995.

Destroying the screensaver during an idle lock can make Hyprland report idle again. The idle service may then start a second cycle while the lock is still pending, launching a new screensaver whose terminal is immediately destroyed. Its ttfx renderer consequently aborts after receiving EIO.

Block idle-cycle startup and recheck delayed screensaver launches whenever:

  • the idle service’s lock subprocess is running, or
  • the in-process omarchy.lock service reports locked, including lockRequested.

The in-process check avoids the fall-through behavior of the existing shell IPC guard during lock
transitions.

This complements #6813: that PR fixes renderer/supervisor teardown, while this change prevents an entirely new screensaver from existing launched during the pending lock.

Tests:

  • bash test/shell.d/idle-test.sh
  • ./test/all — all applicable tests pass; three packaging-coverage tests require an omarchy-pkgs checkout.

Fixes omacom#6995.

Destroying the screensaver during an idle lock can make Hyprland
report idle again. The idle service may then start a second cycle
while the lock is still pending, launching a new screensaver
whose terminal is immediately destroyed. Its ttfx renderer
consequently aborts after receiving EIO.

Block idle-cycle startup and recheck delayed screensaver launches
whenever:

- the idle service’s lock subprocess is running, or
- the in-process omarchy.lock service reports locked, including
lockRequested.

The in-process check avoids the fall-through behavior of the
existing shell IPC guard during lock
transitions.

This complements omacom#6813: that PR fixes renderer/supervisor teardown,
while this change prevents an entirely new screensaver from existing
launched during the pending lock.

Tests:

- bash test/shell.d/idle-test.sh
- ./test/all — all applicable tests pass; three packaging-coverage
tests require an omarchy-pkgs checkout.
Copilot AI balanced review requested due to automatic review settings August 16, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents idle-cycle races from launching screensavers while session locking is pending.

Changes:

  • Detects active lock subprocesses and in-process lock state.
  • Guards idle-cycle startup and delayed screensaver launches.
  • Adds unit and structural regression coverage.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
shell/plugins/services/idle/Service.qml Applies lock-transition guards.
shell/plugins/services/idle/IdleModel.js Adds shared lock-state logic.
test/shell.d/idle-test.sh Covers lock detection and guard placement.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 6f47c41, against the merge-base with quattro (7488ead). The head has not moved since our previous pass, which recorded no SHA and posted nothing, so this is the first reply you get from us and it covers the whole change rather than a delta.

The failure mode we went looking for. A guard keyed on a transition flag that is set but never cleared is the mirror image of the bug you are fixing: it would suppress the screensaver and the idle lock for the rest of the session. This one does not latch. lockProcess.running is cleared by Quickshell on exit, on failed start and on signal death, and omarchy-system-lock is bounded — the only & in it is the best-effort 1Password subshell, which non-interactive bash does not wait for. lockService.locked is lockRequested || sessionLock.locked || sessionLock.secure, and each has a clearing path: finishUnlock() at shell/plugins/lock/Service.qml:151 and the compositor-forced drop at :254. firstPartyServiceFor("omarchy.lock") does resolve at runtime — _syncServices() in shell/shell.qml:323 registers every enabled service plugin and the manifest id matches — and when it returns null the !! in IdleModel.lockInProgress degrades the guard to lockProcess.running rather than throwing.

One finding, medium. shell/plugins/services/idle/Service.qml:98 — the skipped idle edge is never re-armed. startIdleCycle() is reached only from handleIdleChanged(), that is, on an IdleMonitor.isIdle transition. lockSystem() has already cleared idledThisCycle and stopped every timer, so when the guard consumes the reasserted-idle edge and the lock then clears without user input — beginLock() returning false on missing PAM, or onLockStateChanged(false) at shell/plugins/lock/Service.qml:254 — isIdle stays true, emits no further transition, and nothing calls startIdleCycle() again. The machine sits unlocked and unblanked with nobody at it until someone supplies input. Before this change that same reasserted-idle edge started a fresh cycle, which re-armed lockTimer and retried the lock about 150s later on the default timeouts; that retry is what the guard removes. The trigger is narrow, since it needs the lock to have already failed, but the idle churn it rides on is the routine case this PR is about. Neither new test covers it: both regexes do match at this head, but neither exercises "guard true, then the condition clears while the monitor is still idle".

Nothing was pushed for it. The re-arm wants the lock service bound as a property so lockedChanged can be connected, and that is a shape decision in a state machine three open pull requests are currently contending for, so it is the maintainer's call rather than ours.

Two things that are deliberately not findings. The in-process check does not conflict with the omarchy-shell lock isLocked shell-out on the next line — that one still closes the later race at exec time, and it fails open (bin/omarchy-shell:59 gives it a 2s timeout and discards stderr), which is exactly why the direct read is the right addition. And suppressing idle cycles while locked strands nothing, because the only DPMS-off in the tree is the lock service's own idleBlankTimer.

Tests. On a disposable VM built from the Omarchy ISO, with the compositor rebooted onto this branch and pgrep -af quickshell confirming it was serving this tree: test/shell.d/idle-test.sh 14/14, system-lock-test.sh 1/1, lock-stranded-recovery-test.sh 14/14, hyprland-session-locked-test.sh 11/11. sleep-lock-test.sh failed once on "sleep lock gives up within its budget" at 2.19s, then passed 19/19 three runs in a row — a timing flake on a freshly rebooted VM, in a file this pull request does not touch.

Who reviewed it. Claude Opus 5 in Claude Code, with Codex at xhigh reasoning as an independent second opinion. Codex reached the same re-arm conclusion, which had already been written down before it ran, and its independence is not currently guaranteed — it can read the first reviewer's working notes, so treat that agreement as weaker than it looks. What it contributed on its own terms: the hyprctl switchxkblayout call at bin/omarchy-system-lock:11 is the one genuinely unbounded step in the lock script, making a wedged compositor the only way lockProcess.running stays true indefinitely; and the second regex is loose enough ([\s\S]*? crosses the end of the function) to pass against a decoy guard placed after startIdleCycle(). It rated the missing re-arm high; medium is our reading, because it cannot fire unless locking is already broken.

This is waiting on the maintainer rather than on you: #7131 fixes the same race a different way and only one of them can land.

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #7131, which covers the same idle lock transition guard. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

@bjarneo bjarneo closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idle cycle restarts during a pending lock and launches a second screensaver into it — new ttfx aborts (isLocked guard passes while lock-pending)

4 participants