Skip to content

Keep the keyboard backlight level when the lock blanks again before a wake - #15908

Merged
omarchybot merged 4 commits into
quattrofrom
fix/issue-12994-keyboard-backlight
Oct 29, 2026
Merged

omarchybot merged 4 commits into
quattrofrom
fix/issue-12994-keyboard-backlight

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

After a suspend from the lock screen, the keyboard backlight comes back at 0 on unlock, with no hibernate hook involved (#12994).

The lock blanks with omarchy-brightness-keyboard off and wakes with omarchy-system-wake, which runs omarchy-brightness-keyboard restore. off used brightnessctl -s, which saves whatever the level is at that moment, then set 0. The lock re-arms its blank timer without waking in between in two places: after a resume it sees while the displays are off (the fingerprintResumeTimer branch in shell/plugins/lock/Service.qml), and when a screen arrives (onScreensChanged). So lock, blank, suspend, resume and five seconds without input is a second off while the backlight is already 0, and it saves that 0 over the level the first one saved. Unlock then restores 0.

off now records the level in $XDG_RUNTIME_DIR only when nothing is already saved, and restore consumes the record, so the level from before the first blank survives any number of blanks before a wake. A backlight that was off before the lock stays off, and a wake with nothing saved (an idle cycle that ended before the lock) leaves the backlight alone instead of restoring an old level. Blank and wake run as separate processes, so both take a lock and each runs whole. A level that cannot be read is left lit rather than blanked with no record of it, and a restore the device rejects keeps the record for the next wake.

This does not change the hibernate hook, which sets the backlight to 0 without saving it; #13729 and #14066 cover that. This fixes the backlight half of #12994 and does not close it: the keyboard-layout half is a separate question for the maintainer and is not touched here.

The lock blanks with `omarchy-brightness-keyboard off`, which saved the current level with `brightnessctl -s` before setting 0, and wakes with `restore`. Since the lock re-arms its blank timer after a resume (and when a screen arrives) without waking in between, a second blank saved the 0 the first one had set, and unlock restored 0.

`off` now records the level only when nothing is already saved, and `restore` consumes it, so the level from before the first blank survives any number of blanks. Blank and wake run as separate processes, so both take a lock; a level that cannot be read is left lit, and a restore the device rejects keeps the level for the next wake.

Co-Authored-By: Codex Medium <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR keeps the keyboard brightness saved before the first blank until a wake restores it.

  • Repeated lock blanking keeps the keyboard backlight's original level.

The previous test-cleanup finding is fully addressed. No new actionable issues were found.

Reviews (3) · Last reviewed commit: "Silence and reap the overlap test's back..." · Reviewed by Greptile

Comment thread bin/omarchy-brightness-keyboard Resolved
omarchybot and others added 2 commits October 19, 2026 03:37
A save that creates the record and then fails to write it, as a full runtime directory does, left an empty file. off checked only that the file existed, so it blanked anyway, and restore discarded the empty record without restoring: the keyboard stayed dark. off now removes a record it could not write and blanks only over a non-empty one, and an empty record left behind is replaced by the next off.

The tests now hold a blank paused mid-save while a wake starts, which fails when the flock is removed, and check that a rejected restore leaves the backlight where it was.

Co-Authored-By: Codex Medium <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without the first check, a save guard that left an empty record in place passed: off skipped the blank and restore found the light still on. Without the second, a blank that never reached its save let the overlap test run restore first.

Co-Authored-By: Codex Medium <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 19, 2026
@omarchybot omarchybot added ready Good to merge and removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 19, 2026
docs/testing.md asks background fixtures to send their output elsewhere and be cleaned up on exit. The exit trap releases the paused blank and waits, since killing the backgrounded subshell would leave the script under it running against the deleted directory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 19, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed and verified on a worker: it fixes the backlight half of #12994. I pushed one fix and tightened the tests.

The bug is real. On a worker built from the Omarchy ISO, I made a real keyboard backlight LED with the kernel's uleds module and ran it through the stock brightnessctl. The sequence was the lock blanking, blanking again before a wake, then waking. On quattro (60f5b49) the light comes back at 0. On this branch it comes back at the level from before the first blank. A single blank and wake, and a backlight that was already off before the lock, behave the same on both. 20 overlapping blank-and-wake pairs still end at the saved level. The double blank comes from shell/plugins/lock/Service.qml: the fingerprintResumeTimer branch and onScreensChanged both re-arm the blank timer without a wake.

Pushed:

  • b394507: off only blanked when the record file existed, so a save that created the file but failed to write it (a full $XDG_RUNTIME_DIR) still blanked. restore then threw away the empty record and the keyboard stayed dark. off now removes a record it could not write and blanks only over a non-empty one. A test covers an empty record left behind.
  • f94e9ab: test-only. A new test pauses a blank in the middle of its save and starts a wake, so it fails if the flock is removed. The failed-restore test now also checks the light stays where it was. Each new test fails against a mutant of the script and passes on the fix.
  • 44ecfe7: as Greptile pointed out, docs/testing.md asks tests to silence their background jobs and clean them up. The overlap test's jobs now write to /dev/null, and the exit trap releases the paused blank and waits for it. Killing the jobs instead would leave the script under them running. When I forced a failure mid-blank, the test exits 1 with nothing left running.

Tests: ./test/cli passes on the worker. In ./test/shell, brightness-keyboard-test.sh passes, and it passed three times in a row. 10 files fail (ascii, background-instant-reload, background-intro-clone, branding-about-animation, brave-widevine, hyprland-startup-cursor-cold, i18n, passwordless-grant-lifecycle, runtime-smoke, screenshot-sanity), and they fail the same way on quattro. background-intro-lifecycle-test.sh sometimes passes and sometimes fails, on quattro as well. CI is green.

Second opinion: Codex Medium reviewed four rounds, and its independence from this review is not guaranteed. In the first round it found the empty-record case on its own, which matches the Greptile comment. It also agreed that the overlap had no test. In the second round it found two ways the new tests could pass when the code was wrong, and both are fixed in f94e9ab. Its last two rounds, the final one on this head, found nothing. One finding was left unchanged: if every wake fails to restore the level, the record is kept, so a level the user sets afterwards with the brightness keys can be overridden at the next lock. That only happens on a device that rejects the restore but accepts a later set. Keeping the record for a retry is deliberate, and Codex withdrew the finding.

This does not close #12994, because the keyboard-layout half is untouched, and the hibernate hook is #13729 and #14066. It is waiting on the maintainer.

@omarchybot
omarchybot merged commit 0c29fa5 into quattro Oct 29, 2026
2 checks passed
omarchybot added a commit to marcindyguda/omarchy that referenced this pull request Nov 1, 2026
…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]>
omarchybot added a commit to mohan314e/omarchy that referenced this pull request Nov 1, 2026
…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]>
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
berenddeboer pushed a commit to berenddeboer/omarchy that referenced this pull request Nov 6, 2026
… wake (omacom#15908)

* Keep the keyboard backlight level across a second blank before a wake

The lock blanks with `omarchy-brightness-keyboard off`, which saved the current level with `brightnessctl -s` before setting 0, and wakes with `restore`. Since the lock re-arms its blank timer after a resume (and when a screen arrives) without waking in between, a second blank saved the 0 the first one had set, and unlock restored 0.

`off` now records the level only when nothing is already saved, and `restore` consumes it, so the level from before the first blank survives any number of blanks. Blank and wake run as separate processes, so both take a lock; a level that cannot be read is left lit, and a restore the device rejects keeps the level for the next wake.

Co-Authored-By: Codex Medium <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Treat an empty keyboard backlight record as no record, and test the lock

A save that creates the record and then fails to write it, as a full runtime directory does, left an empty file. off checked only that the file existed, so it blanked anyway, and restore discarded the empty record without restoring: the keyboard stayed dark. off now removes a record it could not write and blanks only over a non-empty one, and an empty record left behind is replaced by the next off.

The tests now hold a blank paused mid-save while a wake starts, which fails when the flock is removed, and check that a rejected restore leaves the backlight where it was.

Co-Authored-By: Codex Medium <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check the blank over an empty record, and that the paused blank started

Without the first check, a save guard that left an empty record in place passed: off skipped the blank and restore found the light still on. Without the second, a blank that never reached its save let the overlap test run restore first.

Co-Authored-By: Codex Medium <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Silence and reap the overlap test's background jobs

docs/testing.md asks background fixtures to send their output elsewhere and be cleaned up on exit. The exit trap releases the paused blank and waits, since killing the backgrounded subshell would leave the script under it running against the deleted directory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Omarchybot <[email protected]>
Co-authored-by: Codex Medium <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 0c29fa5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants