Repository navigation
Do not save or restore 0 in omarchy-brightness-keyboard - #19832
AxxzyWasTaken wants to merge 1 commit into
Conversation
[Medium impact] The brightness change appears safe to merge; the previous missing-test finding remains outstanding. Findings
SummaryUpdates
No new findings were accepted. Reviews (3) · Last reviewed commit: "Do not save or restore 0 in omarchy-brig..." · Reviewed by Greptile |
|
Reviewed the full diff, blank/wake callers, saved-state users, and regression tests at I am handing that existing-record handling and its regression cases to #19134 for incorporation with credit to @AxxzyWasTaken, keeping the fix with the earlier contribution. The handling on both GPT-6 High in Codex, Opus 5.5 High, and muse-wonder via pi (thinking high) reviewed the source. Both review models found no concrete defect here, but disagreed about the carrier: Opus preferred #19134, while muse-wonder preferred this PR for its existing-zero coverage. Their agreement is not guaranteed to be independent. No tests ran in this session because this competing fix is being left for the maintainer to choose between; physical backlight and Aurora behaviour remain unverified on this head. This PR remains open awaiting that decision. |
A blank taken before this fix can leave a saved zero. Treat it as no record in both off and restore: off must save a newly lit level before blanking it, and restore must leave an externally set level alone. Incorporate the existing-record handling and regression coverage from omacom#19832 into the earlier fix. Co-Authored-By: AxxzyWasTaken <axxzytte@gmail.com> Co-Authored-By: GPT-6 (effort not exposed) <noreply@openai.com>
When the keyboard backlight is already at 0 (for example, turned off by an ambient-light or lid daemon such as aurora-kbd-light, or manually off), `omarchy-brightness-keyboard off` previously recorded 0 and wrote 0 again. On the next wake, `restore` then wrote 0 over whatever had lit the backlight in the meantime, turning it back off and latching auto-backlight daemons off until manually re-enabled. Only treat positive integer levels as savable or restorable: leave an already-off backlight unrecorded and untouched on `off`, and treat any stale 0 record like an empty record on both `off` and `restore`.
|
Rebased onto |
6cea1bc to
7ca5140
Compare
| if [[ ! $saved_level =~ ^[1-9][0-9]*$ ]]; then | ||
| rm -f "$saved" | ||
| level="$(brightnessctl -d "$device" get)" | ||
| if [[ $level =~ ^[0-9]+$ ]] && ! echo "$level" >"$saved"; then | ||
| if [[ $level =~ ^[1-9][0-9]*$ ]] && ! echo "$level" >"$saved"; then |
There was a problem hiding this comment.
This changes how off and restore handle zero, but the described brightness-keyboard-test.sh is missing and no existing test exercises these branches. AGENTS.md requires a regression test for a bug fix that changes logic, so this requirement must be met before merging. Add a focused test that fails before the fix and passes afterward, checking that an initially dark keyboard stays untouched and stale zero records cause no brightness writes.
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!
|
Compared GPT-6 in Codex (effort not exposed) checked both current diffs, the complete command files, and the blank/wake callers. The duplicate-close check refused to close this because the configured second reviewer, Opus 5.5 High, did not answer; its availability probe also failed. This head received no second review in this session. No worker tests ran because the session stopped at that unresolved duplicate/competing-fix decision. The current diff contains no regression test, and Greptile's missing-test finding remains open. Both PRs remain open for the maintainer; #19134 also currently has a merge conflict. No changes were pushed. |
A blank taken before this fix can leave a saved zero. Treat it as no record in both off and restore: off must save a newly lit level before blanking it, and restore must leave an externally set level alone. Incorporate the existing-record handling from omacom#19832 into the earlier fix. Co-Authored-By: AxxzyWasTaken <axxzytte@gmail.com> Co-Authored-By: GPT-6 (effort not exposed) <noreply@openai.com>
|
Closing in favor of #19134, which already includes the identical fix and tests and is now conflict-free. |
Problem
When
omarchy-brightness-keyboard offruns while the keyboard backlight is already at0, it saves0to${XDG_RUNTIME_DIR:-/tmp}/omarchy-brightness-keyboard-$deviceand runsbrightnessctl -d "$device" set 0.On the next wake,
omarchy-brightness-keyboard restorereads that saved0and writes0back to the LED device, overwriting whatever lit the keyboard in the meantime:aurora-kbd-lightblank/sys/class/leds/*kbd_backlight/brightnessto0on lid close or display sleep, fade the backlight back up on wake/lid-open, and treat an external write of0while awake as the user manually turning the backlight off (off until turned on). Saving and restoring0causesomarchy-system-waketo slam the freshly restored backlight back to0and permanently latch auto-backlight off until manually re-enabled.restoreturns it back off on wake.Fix
bin/omarchy-brightness-keyboard:^[1-9][0-9]*$) as a saved or savable backlight level.offsees the backlight is already0, neither save a record nor callbrightnessctl set 0(leaving an already-off backlight off across lock/unlock without clobbering anything that lights it later).0record like an empty record:offremoves and replaces it if the backlight is lit (or just removes it if already0), andrestorediscards it without writing0.test/shell.d/brightness-keyboard-test.shcovering already-offoff/restorewithout writes or clobbering, and stale0records on bothoffandrestore.Verification
bash test/shell.d/brightness-keyboard-test.sh(12/12 passing)bash test/shell.d/brightness-keys-test.sh(10/10 passing)bash test/shell.d/brightness-display-test.sh(17/17 passing)bash -n bin/omarchy-brightness-keyboard test/shell.d/brightness-keyboard-test.sh