Skip to content

Keep the lock through a pending suspend, and replay the design after it - #150

Merged
Xpond merged 1 commit into
mainfrom
sleep-hook-relock
Dec 6, 2026
Merged

Xpond merged 1 commit into
mainfrom
sleep-hook-relock

Conversation

@Xpond

@Xpond Xpond commented Dec 6, 2026

Copy link
Copy Markdown
Owner

Suspending and unlocking straight away put the lock in a loop: the lock screen kept appearing and disappearing until the machine slept anyway.

Cause

Since #90 the lock holds a suspend until it has blanked (status reports secure only then), so the design's entrance plays before the machine sleeps. A password accepted during that hold unlocked the session. Omarchy's omarchy-system-sleep-lock was still waiting for secure, saw an unlocked session, and locked again. That repeated until its 12 s budget ran out and it suspended with "Screen did not lock before sleep". Each round showed the desktop for about 0.1 s.

Not caused by 4.6 or #149: the hook is byte-identical in 4.5.0-3 and 4.6.0, and the same repro loops on the pre-#149 patch with 4.5. Stock Omarchy releases the suspend after 0.6 s, so it never hits this.

Fix

  • Held unlock: a password or fingerprint accepted while logind reports PreparingForSleep keeps the lock and logs unlock: held for sleep. The entrance still plays, the machine sleeps, and you unlock after the wake. A suspend can't be cancelled, so there is no way to unlock and stay awake.
  • Resume: the watch that lights the display after a suspend (resumeWatch) now runs whenever the lock is up, not only when blanked. Typing during the hold kept the display on, so the design woke already played out. On resume it now hides the design so the first key plays it, and clears any half-typed password (the relock loop used to clear it).
  • Outside a pending suspend, nothing changes.

Tests

  • tests/all.sh: 284 checks pass against 4.6 with the patched lock files.
  • lock-process.py runs Omarchy's real sleep hook against the lock: a password during the hold keeps the lock, the hook exits secure inside its budget, and after a resume the field is empty and the first input replays the design. It fails without the fix (an unlock went through a pending suspend), without the wider resume watch, and without the password clear.
  • Tested by hand: suspend, type and submit the password during the hold, wake, and unlock.

The lock holds a suspend until it has blanked, so the design's entrance is
seen before the machine sleeps (#90). A password accepted in that hold
unlocked the session; omarchy-system-sleep-lock took that for a lock never
made and locked again, every time, until its 12 s budget ran out and it
suspended with "Screen did not lock before sleep". Each round showed the
desktop for about 0.1 s.

- A password or fingerprint accepted while logind is PreparingForSleep keeps
  the lock (unlock: held for sleep). The entrance still plays, the machine
  sleeps, and the unlock happens after the wake.
- A resume is now seen whenever the lock is up, not only when blanked: typing
  keeps the display on, and the design then woke already played out. The
  resume hides the design for the first key to play, and clears a half-typed
  password, which the relock loop used to clear.
- lock-process.py runs Omarchy's own sleep hook against the lock.
@Xpond
Xpond merged commit 5dd90d0 into main Dec 6, 2026
1 check passed
@Xpond
Xpond deleted the sleep-hook-relock branch December 6, 2026 05:41
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.

1 participant