Repository navigation
Fix keyboard backlight restore after screensaver dismiss - #10366
marcindyguda wants to merge 7 commits into
Conversation
The backlight keys stay bound on the lock screen, so a user can change the level after a blank. Restore only treated a nonzero level as their choice, so stepping down to 0 while locked was undone by the next wake. Clearing the marker on up, down and cycle makes any level chosen by hand final. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
A failed set leaves the keyboard blanked, so the saved level is still the one to restore. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
Removing the marker before brightnessctl -r meant a failed restore left the keyboard dark with nothing for the next wake to retry. brightnessctl -r exits 0 when its write is refused, so the level is read back instead: the marker goes once the keyboard is lit, whether the restore lit it or it already was. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
|
Reviewed and verified at 3ff0554. The cause is as described: How it was checked. The test in this PR only greps for strings, so I wrote a separate reproduction. It ran on a disposable Omarchy worker against a real LED device ( Pushed to the branch, from the review rounds:
Second opinion: Codex Medium reviewed four rounds. It found both of the follow-up defects above, agreed the approach is the right one, and its last round on 3ff0554 found nothing further. Its agreement is not guaranteed to be independent of this review. Competing fixes: #12960 (only save when lit) and #12502 (only restore at 0, plus a wake on resume in the lock service) cover parts of the same bug. Run through the first eight of the same checks, #12960 fails four and #12502 fails two, including re-lighting a keyboard the user turned off after a lock cycle. Neither can tell a deliberate 0 from a blank, and the marker here can. #12502's resume Not fixed here, for the maintainer:
This now closes #12942, #14011, #10767 and #12274; it does not fix #6667, where Dell's firmware timeout zeroes the light before the lock. Waiting on the maintainer: the review is done, and the one failing CLI test is |
[Low impact] The latest changes appear safe to merge; the earlier shared Findings
SummaryUpdates keyboard brightness changes so they do not hold the lock while showing the OSD.
Reviews (3) · Last reviewed commit: "Release the keyboard lock before the OSD..." · Reviewed by Greptile |
| # later restore without a preceding off (e.g. screensaver dismiss, which wakes | ||
| # via omarchy-system-wake without ever blanking the keyboard) is a no-op | ||
| # instead of restoring a stale brightnessctl save. | ||
| state_marker="${XDG_RUNTIME_DIR:-/tmp}/omarchy-keyboard-backlight-off" |
There was a problem hiding this comment.
If XDG_RUNTIME_DIR is unset, the marker uses the same predictable /tmp path for every user. Another user can create that file, causing an unpaired wake to attempt a stale brightness restore. Use user-private state so one user's marker cannot affect another user's keyboard.
How this was verified: The fallback path is shared across users, and restore checks only for the file's existence before calling brightnessctl -r.
|
Tested this on a 2017 Google Pixelbook (Eve), Omarchy 4.0.4, by running this PR's
So this also covers #12274 (a manual change, including turning it off, gets reverted on the next wake) and the repeated-blank case in #12942 / #14011. AI disclosure: tested with help from Claude Code (Opus 5.5); I ran it on the hardware. |
…ware levels omacom#15908 landed the repeated-blank and unpaired-restore fixes on quattro with a level record and a lock, so this branch now builds on that instead of its own marker. What it still adds: a level changed with the keys while blanked replaces the record, unless the key changed nothing (down at 0), and restore leaves a backlight that something else lit since the blank, as a firmware key does, at its level. The grep-only keyboard-backlight-test.sh is replaced by behavioural cases in quattro's brightness-keyboard-test.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A key that changes the level now deletes the saved record, so it is a third writer beside off and restore. Outside the lock, a key landing between off saving the level and setting 0 deleted the record before the blank, and the next wake left the keyboard dark; and a key landing inside a restore was overwritten by it. The keys test now also steps up and back down to 0 while blanked, which only the key path's record deletion keeps off. Co-Authored-By: Codex Medium <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This branch stopped merging after #15908 landed on What What this still fixes. On
How it was checked. On a disposable Omarchy worker with a real LED device ( Earlier bot findings. Of Greptile's four comments on 3ff0554: down at 0 cancelling the restore is fixed (unchanged levels keep the record). A failed read losing the level was already fixed on Second opinion. Codex Medium and muse-wonder (via pi, thinking high) reviewed the merge. Both found the race on the unlocked key path, which bb98cf4 fixes, and Codex asked for the up-then-down case that is now in the test. Their second round, on bb98cf4, found nothing further. Their agreement is not guaranteed to be independent of this review. @marcindyguda, the description still describes the marker file and the old test. Updating it to the change above would help whoever merges it, but the code needs nothing more from you. Waiting on the maintainer: the |
A manual change held the lock through omarchy-osd, which can wait on a stalled shell, so held keys, blank and wake queued behind it. A key the device rejected still showed the level it never set. Both come from omacom#10364. Co-Authored-By: Chris AtLee <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I pushed one more commit to this branch, 34f80ef. It carries over two pieces from #10364 by @catlee, who is credited as co-author:
What was checked. Everything ran on a fresh Omarchy worker at 34f80ef, against
Claude Opus 5.5 did the review. Codex Medium and muse-wonder (via pi, thinking high) reviewed the commit as second opinions and found nothing to change. They agree with the reading above, but their independence from it is not guaranteed. What's left.
|
Problem
After the screensaver shows and is dismissed (before the lock deadline), the keyboard backlight stays dark instead of keeping its previous brightness.
Root cause
shell/plugins/lock/Service.qmlblankProcess) runsomarchy-brightness-keyboard off=brightnessctl -s set 0(save + off).bin/omarchy-system-wake) runsomarchy-brightness-keyboard restore=brightnessctl -r.shell/plugins/services/idle/Service.qmlcancelIdleCycle) also runsomarchy-system-wakewithout any precedingoff, sorestoreapplied a stale save (often0from an earlier cycle) and clobbered the still-lit keyboard. A repeatedoffwhile already at zero had the same clobbering effect on the save file.Reproduced live on a MacBook (
kbd_backlight, max 255): strayrestorewith no precedingoffreset a lit keyboard to the stale saved value.Fix
bin/omarchy-brightness-keyboardnow pairsoff/restorewith a marker file (${XDG_RUNTIME_DIR:-/tmp}/omarchy-keyboard-backlight-off):offonly saves (-s) when the keyboard is actually lit; a repeatedoffat zero is a plainset 0that leaves the save intact.restoreis a no-op without the marker (screensaver dismiss), one-shot (clears the marker), and leaves an already-lit keyboard alone.No caller changes needed;
omarchy-system-wakekeeps callingrestore.Verification
test/shell.d/keyboard-backlight-test.shpasses;idle-test.shpasses (bin-style-test.shfailure is pre-existing on clean checkout, unrelatedomarchy-remove-ai-openclaw).25 -> off -> 0 (marker) -> restore -> 25 (marker cleared); strayrestoreon a lit keyboard is a no-op.Fixes #12942
Fixes #14011
Fixes #10767
Fixes #12274