Repository navigation
Conversation
A blank saves the current level before writing zero, and a wake restores whatever was saved. Resume is the one path that reaches a blank with no wake in front of it, so the level still holds the zero the pre-suspend blank wrote and that blank saves zero over the real level. Every later restore then puts the backlight back to off, permanently. Wake on the suspend gap instead of only re-arming, so the level is real again before the next blank records it. Restore applies the saved level only while the backlight is still at the zero the blank wrote. Any other level was set after the blank -- the backlight hotkeys stay bound while locked -- so it is newer than the saved value and has to survive the wake. A level deliberately left at zero still saves and restores as zero, so turning the backlight off by hand is not undone on the next wake. Restore the backlight before the display in omarchy-system-wake. The brightness write reaches sysfs immediately while the display call goes through Hyprland IPC, which lid transitions can stall, and runWake() drops a wake request while the previous one is still running. Reported in omacom#9339, omacom#10105 and omacom#7650. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Automated AI review
Verified: the three changes do what the description says for a non-zero level. One side effect is worth addressing: a keyboard deliberately turned off with the hotkeys can now come back on after a lock-then-sleep. Two smaller gaps that this PR does not introduce are noted below. Verified in source and in sandboxed runs of the changed scripts:
A hotkey zero is relit after a lock-then-sleep
The same gap already exists on the merge-base when the screensaver is dismissed after a hotkey zero, and when the lock screen gets input before the first blank. The test "restore keeps a deliberate zero off" starts with Impact: a keyboard backlight turned off by hand comes back on after this kind of sleep, and again after unlock. This contradicts the description's statement that a deliberate zero is kept. Suggested change: make the hotkey paths record the new level, for example Residual gap, not introduced by this PR (dropped wake during an IPC stall): Residual gap, not introduced by this PR (first sleep of a login): brightnessctl 0.5.1 keeps the saved level in Description note: the suspend-gap branch only runs when the blank timer is still armed at suspend (the timer is one-shot). A lock that blanked more than 5 s before sleep has no pending timer. That case is already handled by the first input after resume, which restores the saved level on both branches. The fix therefore targets lock-then-sleep and input shortly before sleep, rather than every resume. Review informationTest scope: Source review of head AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted cross-checks, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Reviewed at 6c6ab91 and reproduced on an Omarchy worker VM against How it was tested. A
Each fix was also reverted on its own. With One limit, and it is not new. A level turned to 0 with the hotkeys while an older level is saved still comes back on after a lock, on Suite. Second opinion. Codex at medium effort reviewed the diff and found no defect. It agreed the change is proportionate and the restore guard behaves as intended; that agreement is not guaranteed to be independent. It noted that the suspend path only applies when a blank is still pending at suspend (lock-then-sleep, or input shortly before sleep), which is narrower than the description's walkthrough suggests. This pull request now closes #10767. It is labelled |
…s record omacom#15908 replaced brightnessctl's save with a record taken at the first blank, which already keeps the level across a second blank after a resume. That is what the lock service's wake-instead-of-rearm change was for, and with the record in place a wake there no longer changes the keyboard, so that change is dropped along with the leds path override nothing reads any more. What quattro does not cover is omacom#10767: restore still puts the record back over a level the hotkeys set while blanked. restore now consumes the record without writing when the backlight is already lit, and the test for it moves into quattro's brightness-keyboard-test.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This had stopped merging cleanly: since the last review, What this pull request now does. The fix for #10767 is kept, rebuilt on #15908's record: when What was dropped, and why. The How it was tested, on an Omarchy worker VM against
The new test fails on Not covered, on Second opinion. Codex at medium effort and muse-wonder (via pi, thinking high) reviewed the resolution. Neither found a defect in it, and both agreed with dropping the This is labelled |
[Medium impact] The changes affect keyboard brightness during lock and wake workflows. Add the required regression test before merging. FindingsSummaryThe PR keeps a newer nonzero keyboard brightness choice during wake.
Reviews (2) · Last reviewed commit: "Merge quattro: drop the keyboard backlig..." · Reviewed by Greptile |
| if [[ $current =~ ^[0-9]+$ ]] && (( current > 0 )); then | ||
| rm -f "$saved" | ||
| elif [[ ! $level =~ ^[0-9]+$ ]] || brightnessctl -d "$device" set "$level" >/dev/null; then |
There was a problem hiding this comment.
restore still overwrites a brightness choice of zero made while locked. After off saves 3, a user can raise the light and then use down or cycle to turn it off again. The new current > 0 check misses that change, so the next wake restores 3.
To preserve this choice too, have successful hotkey changes update the saved level under the same lock, and add a test for turning the light off while locked.
|
Tested
Not tested: the backlight key while actually locked (by eye it was inconclusive, and the lock logs don't show it), and suspend/resume. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| current="$(brightnessctl -d "$device" get)" | ||
| # Lit after a blank means the hotkeys set it while locked, which is newer than the record. | ||
| if [[ $current =~ ^[0-9]+$ ]] && (( current > 0 )); then | ||
| rm -f "$saved" |
There was a problem hiding this comment.
The new restore branch has no regression test. AGENTS.md requires a bug fix with logic to include a test that fails before the fix and passes afterward. This requirement must be met before merging.
Add a test that saves a level with off, changes the brightness to another nonzero level, and checks that restore keeps the newer choice and removes the saved record.
File Used: AGENTS.md (source)
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!
|
Reviewed head The older #10366 now contains the same nonzero restore guard, plus serialization of hotkey changes and removal of the saved record when a hotkey actually changes the level. That covers two cases this guard leaves open: returning to 0 with the hotkeys while blanked, and making a hotkey change followed by another blank before the wake. For those cases, this head retains the older saved level and restores it. #10366 also handles a keyboard lit outside the command, which older #10364 still overwrites. These are the concrete reasons to pursue #10366 for this fix; that branch still needs verification at its current head. Greptile is right that this head has no regression test after the merge carrying #19904's test removal. The separate keyboard-before-display change is a tradeoff: it restores the keyboard before any display IPC wait, but also puts display wake behind the keyboard's blocking lock. That remains a maintainer decision. Codex High, Opus 5.5 High, and muse-wonder via pi (thinking high) checked this comparison. Both second reviewers recommended #10366; their agreement is not guaranteed to be independent. They also identified #10364's no-op |
What's wrong
The keyboard backlight goes off and never comes back. Turning it on by hand doesn't help — the next wake turns it off again.
How it's meant to work
Locking blanks the backlight:
brightnessctl -s)Waking puts it back:
brightnessctl -r)That is correct, as long as step 1 only ever runs while the light is actually on.
Why it breaks
Step 1 remembers whatever it finds — including 0. So a blank that runs while the light is already off remembers 0.
After that, "restore the remembered level" means "set it to 0". Every time. Nothing ever writes a good value back, so it never heals on its own.
So the whole bug reduces to one question: can a blank ever run while the light is already off?
Yes — and only one path does it
A blank is normally preceded by a wake, and a wake restores the light. So the light is on when the blank runs. Fine.
Four places schedule a blank:
:146:181runWake()ran first:551runWake():490:490is the suspend gap. The blank countdown freezes during suspend. On resume it fires late, notices the gap, and re-arms — but it never wakes anything::490fires and re-arms. No wake, so nothing restores the light.Poisoned, permanently.
Resume can't be rescued anywhere else either.
runWake()'s callers are:169,:218,:244,:298and:323, and the last needs real typing or mouse movement on the lock screen. Opening a lid is neither.Fix 1 —
Service.qml:490: wake, don't just re-arm.runWake()arms the timer itself while locked, so the five-second run-up before blanking still happens. The light is simply real again before the next blank records it.A second, separate problem
Restore writes the remembered level no matter what. But the backlight hotkeys still work while locked. So if you set the level yourself on the lock screen, the next wake throws your choice away (#10767).
The level at restore time tells you which happened:
The same rule also covers locking while the light was already off: remembers 0, sees 0, applies 0 — no change, no special case needed.
Fix 2 —
restoreonly writes while the level is still 0.This is also why
offis left as-is. Guardingoffagainst saving 0 would mean a backlight you deliberately turned off is never remembered, and the next wake would switch it back on.Fix 3 —
omarchy-system-wakerestores the keyboard before the display. The display call goes through Hyprland IPC, which lid transitions can stall; the keyboard write goes straight to sysfs and is instant. Doing it first means it is already done if the display call hangs — andrunWake()drops a new wake request while the previous one is still running.OMARCHY_LEDS_PATHfollows the existingOMARCHY_BACKLIGHT_PATHandOMARCHY_DRM_PATHseams, so the new test can run on hardware with no keyboard backlight.Reported in #9339, #10105 and #7650.
Validation: the new
test/shell.d/brightness-keyboard-test.shcovers blank/restore, a level changed while blanked, and a deliberate zero. It fails against the unpatched script and passes on this branch.qmllintreports no new warnings onService.qml../test/allpasses apart from ten files that fail identically on a clean checkout in this environment for unrelated reasons. The three changes were also applied to a running 4.0.4-1 system and exercised through real blank and restore cycles; a full suspend and resume cycle was not manually tested.🤖 Generated with Claude Code
Fixes #10767
Update: changes after merging
quattro(1d06a4b)After this PR was opened,
quattromerged #15908. That PR replacedbrightnessctl -s/-rinomarchy-brightness-keyboardwith a record taken at the first blank and used by the next wake. The merge conflict was resolved in 1d06a4b, and some of the description above no longer matches the diff:Service.qml:490) was dropped, because Keep the keyboard backlight level when the lock blanks again before a wake #15908 now handles that problem. It stops a second blank from saving 0 over the first, so a blank after resume can no longer overwrite the saved level. The "Why it breaks" and "Yes — and only one path does it" sections describe the bug as it was before Keep the keyboard backlight level when the lock blanks again before a wake #15908.restorefinds the backlight already on, the hotkeys set it while it was blanked.restorethen drops the record and keeps that level (Keyboard brightness changes do not update saved state, so screensaver wake restores an old level #10767).omarchy-system-wakestill restores the keyboard before the display.OMARCHY_LEDS_PATHoverride was dropped. The test case moved intoquattro'stest/shell.d/brightness-keyboard-test.sh, which sets the path itself.For validation of the current diff, see #12502 (comment).