Repository navigation
Conversation
Only save brightness when turning off from a non-zero level so a second off does not overwrite the restore value with 0.
|
One restore-state regression was found at Preserve a user-selected zero across separate lock cyclesThe new guard in A synthetic device with maximum brightness 100 reproduced this using the production command with a remapped LED path and a The lock service invokes Impact: the second cycle reverses the user's choice to leave the keyboard backlight off. This requires a prior nonzero saved level in the same login session. Suggested change: distinguish a repeated blank within the same blank/restore cycle from a fresh cycle starting at a user-selected zero. Preserve zero on the latter path while retaining the repeated- Verified: the intended Review informationTest scope: pinned base/head command checks with synthetic LEDs and stubbed Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review. Automated AI review: Astra Medium initial inspection, independent Opus 5.5 High and GPT 6 Sol Xhigh technical assessments, followed by source/evidence verification and post-review adjudication. A fresh Astra Medium check assessed presentation and disclosures, not technical correctness. |
|
There is another edge case tied to this that helps resolve the regression noted by @llstrk: screensaver wake-up and hardware hotkeys ( 1. The Screensaver AsymmetryIn If a user turned on their keyboard backlight via laptop hardware keys (e.g. 2. Solving the Regression and the Screensaver Bug TogetherBecause We can solve both issues cleanly by:
This directly satisfies @llstrk's test case: if a user later turns their backlight to 0 and locks again, there is no lingering saved file from the prior cycle to resurrect the old non-zero level. Suggested Patchsave_file="${XDG_RUNTIME_DIR:-/tmp}/brightnessctl/leds/$device"
[[ -f $save_file ]] || save_file="/tmp/brightnessctl/leds/$device"
if [[ $direction == "off" ]]; then
current="$(brightnessctl -d "$device" get 2>/dev/null || echo 0)"
if (( current > 0 )); then
brightnessctl -sd "$device" set 0 >/dev/null
else
brightnessctl -d "$device" set 0 >/dev/null
fi
exit 0
elif [[ $direction == "restore" ]]; then
current="$(brightnessctl -d "$device" get 2>/dev/null || echo 0)"
# If the keyboard is already illuminated (e.g. toggled via hardware Fn+Space,
# or waking from screensaver which never turned it off), leave it on.
if (( current > 0 )); then
exit 0
fi
if [[ -f $save_file ]]; then
saved_val="$(cat "$save_file" 2>/dev/null || echo 0)"
if (( saved_val > 0 )); then
brightnessctl -rd "$device" >/dev/null
fi
# Unlink the temporary save file so subsequent locks don't resurrect stale state
rm -f "$save_file" 2>/dev/null
fi
exit 0
fi |
Skipping the save whenever the backlight is at 0 also skipped it when the user had turned the light off themselves, so restore brought back the level an earlier lock had saved: brightnessctl's save file outlives each restore. A marker written by off and removed by restore tells a repeated off apart from a fresh one, so only the repeat skips the save. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The keyboard bindings work while locked, so a user can pick 0 between two blanks. With the marker still present, the second off took that 0 for its own and skipped the save, and unlock brought back the level from before the lock. An explicit adjustment now ends the pending blank. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
|
Reviewed and tested on a disposable Omarchy worker. The bug in #12942 is real, and this fixes it. I pushed two commits on top of yours, because skipping the save whenever the backlight is at 0 also skips it when the user turned the light off on purpose. What was wrong. brightnessctl does not delete its save file after What I changed.
What ran, on the worker.
Second opinion. Codex Medium reviewed it. It raised the locked-keys case, which became 111f759. Its re-review of the final head found nothing left to fix. Known limits.
Next. Waiting on the maintainer. No test CI runs on this pull request yet; only the Greptile review was pending when I looked. |
|
|
Closing: #15908 (0c29fa5) fixed #12942 on quattro. omarchy-brightness-keyboard off now records the level only when no record exists and restore consumes it, so a second off no longer saves 0 over the first level, and a user-chosen 0 stays 0. Prepared by Claude Opus 5.5 via Hermes Agent; reviewed under kvnloo's account. |
Summary
omarchy-brightness-keyboard offusesbrightnessctl -s, which saves the current level before zeroing. A secondoffwhile the LED is already 0 overwrites the restore value with 0, so unlock/restoreleaves the keyboard dark.Only save when the current brightness is greater than zero before blanking.
Test plan
./test/shell—brightness-keyboard-restore-test.shFixes #12942