Skip to content

Wake the lock screen on resume and keep wake keys out of the password - #9211

Open
phedoreanu wants to merge 2 commits into
omacom:quattrofrom
phedoreanu:lock-wake-after-resume
Open

phedoreanu wants to merge 2 commits into
omacom:quattrofrom
phedoreanu:lock-wake-after-resume

Conversation

@phedoreanu

@phedoreanu phedoreanu commented Aug 30, 2026 •

Copy link
Copy Markdown

Summary

Two things made the first unlock after resume slower than it needed to be:

  • When the lock had blanked the panel before the machine went to sleep, it stayed dark after resume until the user touched something. The lock now runs a one-second timer while locked; the first tick after resume sees the wall clock jump the frozen shell missed and wakes the panel itself, so the lock screen is lit by the time the user looks at it.
  • The key pressed to wake a dark panel went straight into the password field, so the first attempt failed. The lock already tracks that it blanked the panel (displaysBlank, set by runBlank(), cleared by runWake(), on unlock, or when a display comes back) and hands that to the view: a key pressed while the panel is dark requests the wake and is consumed, the way hyprlock behaves. The view reads the flag before it asks for the wake, since the wake clears it.

test/shell.d/lock-wake-after-resume-test.sh pins both behaviours.

Verification

  • bash test/shell.d/lock-wake-after-resume-test.sh and the existing lock-*, sleep-* and system-lock tests (68 passing)
  • Run as a cloned plugin on a MacBookPro16,1 across several suspend cycles: keys hit while the panel is still dark no longer land in the password field, and the panel wakes on its own after resume without touching the keyboard.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 8fbd1db, and both fixes work as described. Nothing to change.

I tested it on an Omarchy worker VM running this branch's shell, under Hyprland. I reproduced both problems on the base commit (f38eb42) and checked that this head fixes them:

  • Panel stays dark after resume. I locked the session and waited for the lock to blank the panel. Then I froze the shell for 12 s and resumed it, which stands in for a suspend. A real rtcwake freeze never returned on the VM. On base the panel was still DPMS-off 3 s later. On this head it was back on, and the lock logged resume-detected.
  • Wake key typed into the password. With the panel blanked, I sent a and then Return. On base the a went into the field and was submitted, so PAM logged an authentication failure. On this head the key woke the panel and was consumed, and no password was submitted. A key typed once the panel is lit still reaches the field, so normal typing is unaffected.

The lock, sleep, system-lock, video-background and monitor-recovery shell tests pass on the worker, and so does ./test/cli. The new lock-wake-after-resume-test.sh only checks that the code is present; the behaviour is covered by the reproduction above, not by that test. The change is small and in proportion to the two problems.

This fixes the wake-key half of #12398. It does not fix that issue's other cause, auto-repeat from the held lock shortcut, so I have not linked it to close.

Claude Opus 5.5 did this review. There was no second opinion: the configured reviewer, Codex Medium, refused because its daily review budget was spent. The verdict above is one model's reasoning plus what the worker showed. Until a second review runs, this is waiting on that review and then on the maintainer.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 4, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Following the merge of #7806, The merged repeat filter fixes password-field flooding. Automatic wake after resume and consuming the first wake key remain separate work. The reported stale displaysBlank regression also needs fixing; rebasing onto the repeat filter alone is insufficient.

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

@phedoreanu

Copy link
Copy Markdown
Author

Rebased onto quattro with #7806 in. The auto-repeat drop keeps its place at the top of the key handler; the wake-key swallow follows it, still judged before the wake clears the state. Automatic wake after resume and consuming the first wake key are the two things left in this PR.

The stale displaysBlank case, the one #11858's review described, is addressed in a second commit. The view already reads the flag through screenBlank(), which prefers Hyprland's report over what the lock asked for, but that report was only ever polled under a video wallpaper. With a static wallpaper a panel relit behind the lock's back, by a resume that kept its outputs or by a hotplug, left the flag stale and the first password key was eaten until the lock's own wake ran. The poll now also runs while the lock has blanked the panel and stops with the wake, so the swallow follows what the panel actually does. lock-wake-after-resume-test.sh checks the handler order and the poll condition; lock-autorepeat-test.sh still passes here under a compositor.

@phedoreanu
phedoreanu force-pushed the lock-wake-after-resume branch from 8fbd1db to eb7f6db Compare October 4, 2026 17:41
@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with two non-blocking concerns from the previous review still open.

Findings

  1. P2 Clock delays wake displays ▶
  2. P2 Tests miss wake behavior ▶

Summary

The lock now wakes displays after a detected resume and consumes the first key when it believes the displays are blank.

  • The lock screen wakes its display after the shell resumes.
  • The first key at a dark panel wakes it without entering the password.

Reviews (4) · Last reviewed commit: "Wake the lock screen on its own after re..." · Reviewed by Greptile

Comment thread shell/plugins/lock/Service.qml Resolved
Comment on lines +766 to +770
var resumed = lastTick > 0 && now - lastTick > interval + 2000
lastTick = now
if (resumed) {
root.logEvent("resume-detected")
root.runWake()

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.

P2 Clock delays wake displays A gap of more than three seconds between timer callbacks is treated as a resume even when the machine has not slept. If the event loop stalls or the wall clock moves forward while the lock is blanked, this calls runWake(), lights the unattended display, and restarts its blank countdown.

Comment on lines +38 to +47
assert(
/id: monitorDpmsTimer[\s\S]*?running: root\.locked && \(root\.videoBackground \|\| root\.displaysBlank\)/.test(serviceQml),
'the panel state is polled while the lock has blanked it, whatever the wallpaper'
)

// Resume is detected from the clock jump the frozen shell sees on its first
// tick back, and the panel is woken without waiting for input.
assert(
/id: resumeWatchTimer[\s\S]*?running: root\.lockRequested[\s\S]*?now - lastTick > interval \+ 2000[\s\S]*?if \(resumed\) \{[\s\S]*?root\.runWake\(\)/.test(serviceQml),
'the lock wakes the panel on its own after resume'

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.

P2 Tests miss wake behavior These assertions match QML text but never exercise a timer tick, DPMS result, or key event. They can pass despite the wake and polling order producing the wrong behavior, while a harmless rewrite of the matched expressions can fail the test. Behavioral checks using the existing QML fixture approach would cover the blank-to-wake transition and resume timing.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot omarchybot removed the bug Something isn't working label Oct 7, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Classified again at eb7f6db, by Claude Opus 5.5 and Codex Medium separately. The two disagree, so the bug label has come off until that is settled.

Claude Opus 5.5 reads it as a bug fix: the first unlock after resume fails because the key that wakes a dark panel lands in the password field, and the review of 8fbd1db reproduced that on a worker. Codex Medium reads it as an enhancement. The change also adds new behaviour on purpose: the lock now relights the panel by itself after resume, and a key pressed at a dark panel is now consumed the way hyprlock does it. Which reading is right decides how it is reviewed: a fix is reproduced against quattro, while a feature waits for the maintainer to say they want it.

Because of that, the new head has not been run on a worker or given a second review yet. The verification in the earlier comment was done at 8fbd1db and does not carry over to eb7f6db.

I read the source for Greptile's first finding on the new commit, and the race it describes is real. If a hyprctl monitors poll is still running when the panel is woken on a static wallpaper, the poll timer stops. The late answer then records the panel as dark, and nothing polls again to correct it. The next key is consumed, and that key's own wake clears the stale state. So it costs one keystroke, and only when a wake lands during the poll's few milliseconds.

This waits on the maintainer, to decide whether this is a fix or a feature they want.

@phedoreanu

Copy link
Copy Markdown
Author

Greptile's race is closed in the commit just pushed: applyMonitorDpms ignores an answer that lands while the poll timer is off, so a poll caught mid-flight by the wake can no longer record the panel as dark. The test checks for it.

On fix versus feature: the wake-key swallow is the fix, for the unlock that fails after resume because the key that lights the panel lands in the password field, reproduced on the worker at 8fbd1db. The automatic relight after resume is the part that adds behaviour. If the maintainer would rather take the fix on its own, I will split the relight into a separate PR; say so and it is done.

@zoan37

zoan37 commented Oct 10, 2026 •

Copy link
Copy Markdown

Tested a port of this to Omarchy 4.0.4 on an ARM Chromebook (Lenovo IdeaPad Slim 3, MediaTek MT8189, s2idle) today:

  • A key pressed at the blanked lock screen only wakes it, and the panel comes back on its own after resume. Both work well.
  • One small change I needed: with systemctl suspend from an unlocked session, the lock is requested and the machine is asleep within the same second, before resumeWatchTimer has ticked, so lastTick is still 0 and the resume isn't detected. Starting the clock when the timer starts fixes it: onRunningChanged: lastTick = running ? Date.now() : 0.
  • Not covered (and I don't think it's meant to be): when a key press wakes the machine from sleep, that key can reach the password field. On this hardware the EC reports the key after resume, by which time the panel is lit again, so displaysBlank is already false. I tried swallowing the first key for a couple of seconds after a detected resume; it works but it's a timing guess, so I dropped it. A clean fix would compare the key event's own timestamp with the resume time, which the QML key event doesn't expose as far as I can tell.

Thanks for the PR!

@phedoreanu

Copy link
Copy Markdown
Author

Thanks @zoan37, that is a real gap and your fix is in the commit just pushed. systemctl suspend from an unlocked session locks and sleeps inside the same second, so the resume watch had never ticked and its clock was still zero on resume. It now starts the clock when the watch starts, the same way the fingerprint sleep watch on quattro does, and the test asserts it.

The third case you describe, a key that wakes the machine itself and reaches the field once the panel is already lit, is outside what this PR can do: the QML key event carries no timestamp to compare against the resume, and a timed swallow after resume would be a guess, as you found. Left as is.

@omarchybot

Copy link
Copy Markdown
Collaborator

Classified again at 732f4dd, by Claude Opus 5.5 and Codex Medium separately, and the two still disagree: Claude Opus 5.5 reads it as a bug fix, for the first unlock after resume failing because the key that lights a dark panel lands in the password field, while Codex Medium reads it as an enhancement, because the lock now also relights the panel on its own after resume, which is new behaviour on purpose. So it carries no class label, and the new head has not been run on a worker or given a second review; the verification at 8fbd1db does not carry over.

I read the two commits since eb7f6db against the source. applyMonitorDpms now returns while monitorDpmsTimer is stopped, so a hyprctl monitors answer that lands after a wake on a static wallpaper is dropped rather than recording the panel as dark, which closes the race described in the previous comment. resumeWatchTimer now starts its clock when it starts running, so a systemctl suspend from an unlocked session that locks and sleeps inside the first second is still seen as a resume. Both read correctly; neither has been run.

This waits on the maintainer to decide whether it is a fix, or a feature they want. The author has offered to split the automatic relight into its own pull request, which would leave the wake-key swallow here as a plain bug fix.

DanteCpp pushed a commit to DanteCpp/omarchy that referenced this pull request Oct 16, 2026
The lock blanks its panels a few seconds after locking. Hyprland turns them
back on for any key (key_press_enables_dpms) and still hands that key to the
focused password field, so the key pressed only to see the screen became the
first password character and the next attempt failed.

The view already knows its panel is blank. A key pressed while it is, and the
auto-repeats of that key if it is held, now request the wake and are
swallowed; the next key is typed. Text an input method commits while blank is
dropped the same way, since it never passes Keys.onPressed. A lit lock types
every key as before.

Same approach as the view change in omacom#9211.
DanteCpp pushed a commit to DanteCpp/omarchy that referenced this pull request Oct 16, 2026
Suspend freezes the shell, so a lock that blanked its panel before sleep still
thinks it is blank after resume, even though the panel is usually lit again.
The first password key would then be swallowed as a wake key. A one-second
timer runs while locked; the first tick after resume sees the wall clock jump
and runs the wake, which clears the blank state and re-arms the blank timer.

Same as the resume watch in omacom#9211.
When the lock has turned the displays off, the key that wakes the panel
also landed in the password field, so the first unlock attempt after a
blank failed on a stray character. The lock now records when it blanked
the displays, and the view consumes a key pressed while they are off,
after asking for the wake.

The video poll that used to reconcile this with Hyprland is gone since
the lock shows a still poster, so the lock asks Hyprland for the real
display state while it has them off. A panel relit behind its back, by a
hotplug or a resume that kept the outputs on, then stops eating the first
key, and an answer that lands after a wake has stopped the poll is
dropped.
A suspend freezes the shell, so the first tick after resume sees the
clock jump. The lock now wakes the panel then, instead of leaving the
user at a dark lock screen pressing keys to bring it back. The clock
starts when the watch starts, so a suspend from an unlocked session that
locks and sleeps inside the first second is still seen as a resume.
@phedoreanu
phedoreanu force-pushed the lock-wake-after-resume branch from 732f4dd to 48465d9 Compare October 26, 2026 12:48
@phedoreanu

Copy link
Copy Markdown
Author

Rebased onto current quattro (58858ae). #15289 replaced the playing lock video with a still poster and took out displaysBlank, screenBlank() and the hyprctl monitors poll this PR built on, so that part is rebuilt on its own:

  • The service sets displaysBlank in runBlank() and clears it in runWake(), and passes it to the view. The view swallows a key pressed while it is set, after the auto-repeat drop from Drop key auto-repeat in the lock screen password field #7806.
  • While the lock has the displays off, it polls hyprctl monitors -j every 3 s and clears the flag once a display reports DPMS on, so a panel relit behind its back stops eating the first key. An answer that lands after a wake has stopped the poll is ignored.
  • The resume relight is now its own commit, so it can be dropped or split off without touching the swallow if you only want the fix.

All lock-* tests pass, including lock-blank-fingerprint from #15294. sleep-lock-test.sh fails one case, "warns that the session was left unlocked", and fails the same way on a clean quattro checkout.

@omarchybot

Copy link
Copy Markdown
Collaborator

Classified again at 48465d9, after the rebase onto quattro, by Claude Opus 5.5 and Codex Medium separately. They still disagree, so this carries no class label. Claude Opus 5.5 reads it as a bug fix: the first unlock after resume fails because the key that lights a dark panel lands in the password field. Codex Medium reads it as an enhancement, because the lock also relights the panel by itself after resume, which is new behaviour on purpose.

I read the rebuilt diff against the source. The branch still merges cleanly with current quattro (175e63b). The wake-key swallow and the resume relight are now separate commits, 9296105 and 48465d9, so the relight can be dropped without touching the swallow. Because the class is unsettled, this head has not been run on a worker or given a second review. The worker verification at 8fbd1db was done before #15289 rewrote this code, so it does not carry over.

Two related pull requests touch the same code:

This waits on the maintainer. The choice is whether to take the wake-key swallow as a fix, and whether to take the relight with it or split it off, which the author has offered to do.

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.

3 participants