Repository navigation
Preserve keyboard brightness across hardware timeouts - #6760
yashranaway wants to merge 17 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Preserves keyboard-backlight restore state when hardware idle timeouts set brightness to zero.
Changes:
- Checks current brightness before saving and disabling the backlight.
- Adds a configurable LED path and regression tests.
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 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bin/omarchy-brightness-keyboard |
Avoids saving zero after hardware timeouts. |
test/shell.d/brightness-keyboard-test.sh |
Tests save, timeout, and restore behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Looks like a duplicate of #10364, which fixes the same double-save in |
commented
Sep 12, 2026
|
Thanks for flagging this. This PR targets the hardware timeout happening before the first blank call. #10364 appears to save zero in that case. Does it also cover that scenario? |
commented
Sep 13, 2026
|
You're right, #10364 snapshots 0 in the timeout case and restores 0, so it doesn't cover #6667. My mistake. Your approach has a gap the other way though: if I turn the keyboard off manually with down and then lock, off skips the save and restore brings back a stale non-zero level. And it only works at all if some earlier lock saved a non-zero value. At lock time a reading of 0 can't tell "hardware timed out" from "user turned it off". Only the up/down/cycle path knows. I'd rather fix it as #6667 suggests: record the last user-set level in a runtime state file on manual changes, skip set 0 when already at zero, and restore the recorded level. Would you be up for reworking this in that direction, with the manual-off and repeated-blank cases in the test too? |
commented
Sep 24, 2026
|
Good catch. I reworked this to remember successful manual brightness changes, including off, and added regressions for manual off and a timeout before first lock. |
[Medium impact] The PR appears safe to merge; no outstanding findings or new actionable issues remain. SummaryThe PR records keyboard brightness selections, including intentional off, so hardware timeouts do not erase the level to restore. It coordinates persistent and runtime state with hardware changes and adds regression tests. Since the previous review, the permission-dependent read-only-lock test has been changed to skip under root. Reviews (12) · Last reviewed commit: "Skip runtime lock permission test as roo..." · Reviewed by Greptile |
commented
Oct 13, 2026
|
Reviewed at d280924 by Claude Opus 5.5, with Codex Medium as a second opinion. Codex read this pull request and its competitors and raised the firmware-key case below as a finding of its own; where it otherwise agreed with this review, that agreement is not guaranteed to be independent. The fix works. I ran it on a disposable Omarchy worker against the real One regression, which the maintainer should weigh. A light turned off with a key the firmware handles itself (Fn+Space on a ThinkPad, the backlight key on many Dells) never runs Size. The core is proportionate: record successful Competing fixes. #8119, #10364, #12502 and #12960 change the same behaviour. This one is the oldest and the only one that handles a timeout before the first blank, so it is the one carried forward. #12502's choice to leave a positive brightness alone at restore would also avoid the case where a level changed by a firmware key is overwritten on wake.
|
commented
Oct 15, 2026
|
I fixed the two state and failed-save findings in 999fd18 and merged current quattro. A newer TTY choice now wins over an old runtime fallback, and a failed lock-time save keeps a mismatched lit level on instead of losing it. The focused keyboard tests pass. The firmware-handled Fn-key case remains a tradeoff: a zero reading cannot distinguish an intentional off from a hardware timeout. |
commented
Oct 15, 2026
|
Re-reviewed at f13119f by Claude Opus 5.5, with Codex Medium as a second opinion over two rounds. Where Codex agreed with this review, the agreement is not guaranteed to be independent; the TTY race below is its own finding. The fix still works. I ran it on a disposable Omarchy worker against the real What the new commits fix. A failed lock-time save now blanks only when the saved level is readable and matches the lit one, which closes the case where unlock restored the wrong level or nothing at all. An unopenable runtime lock no longer stops the keys: on the worker, with Two defects remain, both in the persistent-versus-runtime fallback.
I have not pushed fixes for these. Both disappear with one state file and one lock, and the rest of the change is right: record Unchanged from the last review: a light turned off by a key the firmware handles itself still comes back on at unlock if an earlier lock saved a lit level. That trade-off is the maintainer's call. Labelled |
commented
Oct 15, 2026
|
Re-reviewed at 23fd875 by Claude Opus 5.5, with Codex Medium as a second opinion. Codex agreed with this review on every point below, and that agreement is not guaranteed to be independent. The fix still works. On a disposable Omarchy worker, with the real The two new commits. Opening an existing runtime lock read-only is sound, because The two earlier fallback defects are still open:
These two commits add more handling to the fallback without settling either of them. As in the last review, one state file and one lock would remove both. Whether the fallback stays is a design question for the maintainer. It is not a defect to patch here. Unchanged: a light turned off by a key the firmware handles itself still comes back on at unlock if an earlier lock saved a lit level. A keyboard that times out before any level was recorded still stays dark. Nothing was pushed. Labelled |
commented
Oct 15, 2026
|
Re-reviewed at dbf80c7 by Claude Opus 5.5, with Codex Medium as a second opinion. Codex agreed with this review on every point below, and that agreement is not guaranteed to be independent. The new commit is sound. It changes only The fix still works. On a disposable Omarchy worker, with the real Unchanged from the last review. The two fallback defects are still open: after storage recovers, a newer runtime file at line 62 keeps receiving every choice, so the persistent file never catches up and a reboot brings back the old level; and a command without Nothing was pushed. Labelled |
commented
Oct 31, 2026
|
Re-checked at dbf80c7 against current This now conflicts with What #15908 covers, and what it leaves. On a disposable Omarchy worker, with the real
One new defect, found by both second opinions and confirmed in the source. If the persistent state directory stops being writable, lines 30-39 switch to the runtime file without reading the persistent one, and the check at line 47 is skipped in that case. So a level saved earlier with the keys is lost for as long as storage stays read-only:
|
Remembers the keyboard brightness selected with up/down/cycle, including an intentional off, so hardware timeouts don't erase the level to restore after unlock. Addresses #6667.
<<< AI wording below >>>
Problem
A zero reading at lock time cannot distinguish a hardware timeout from a manual off. Saving that zero loses the user's lit setting; skipping it without tracking manual changes can restore an older non-zero setting after the user turned the light off. Relying on a previous lock-time save also misses timeouts before the first lock.
Fix
Remember successful manual keyboard brightness selections, including zero, under the hardware lock. Restore only when the saved level differs from the current one, avoiding redundant zero writes that disrupt hardware wake triggers. Share a persistent user state directory between TTY and compositor commands. If saving a manual adjustment fails, try to restore a positive prior hardware brightness and report failure.
Verification
bash test/shell.d/brightness-keyboard-test.shpasses. Changed Bash files pass syntax checks andgit diff --checkpasses. Tests simulate brightness hardware; no Dell firmware test was available.Review follow-up, 1 October
Normal TTY and compositor commands share a persistent preference. If persistent storage is unavailable, a writable runtime fallback stays authoritative for the rest of that session, including after storage recovers. A lit lock records the current level over stale prior-session state. If a replacement save fails but an older preference exists, blanking still works and warns that unlock will use the older level. Manual failed-save rollback only restores positive prior levels. Permission-dependent fixtures skip explicitly under root.
Focused regressions, Bash syntax, and diff checks pass. Dell firmware was not exercised on this host.
Fixes #6667