Turn the keyboard backlight off on idle and make its thresholds configurable - #340
Turn the keyboard backlight off on idle and make its thresholds configurable#340DataKnox wants to merge 4 commits into
Conversation
|
@DataKnox — heads up before you put more time into this: #303 is the same feature and is close to landing. It adds the same two paths ( The good news is the overlap is smaller than it looks, and the parts of yours that don't overlap are the parts I most want. #303 has no idle handling at all. Yours has the three things it's missing:
One more, which I only found by checking the hardware — your Your So what I'd like to propose: let #303 land, and rebase this as a follow-up that extends its script rather than replacing it. Your diff drops from ~336 lines to maybe 80, the review gets much easier, and the ideas above survive — which they won't if this stays a competing implementation and loses the race. Two things worth fixing wherever this code ends up:
Manual override has no visible effect in a lit room. Smaller: Nice work on the hardware testing — the idle behavior is the thing I want in Omarchy and I'd rather it arrive as your follow-up than get lost to a merge race. |
…gurable The ambient light loop from omacom#303 lights the keys in the dark and dims them as the room brightens, but leaves them lit on an untouched laptop, and its thresholds are constants in the script. Three additions, all inside the existing command, which stays the one writer of the LED: - --idle and --active record the idle state under $XDG_RUNTIME_DIR and prod the loop with USR1, so the keys go dark the moment the compositor reports IDLE_SECONDS without input and come back at the first key press or trackpad touch. A new first-party shell service, omarchy.keyboard-backlight, relays the compositor's idle notifier into those two calls; a fast idle -> active flip while a call is still running is re-sent, not dropped. A level set by hand while idle survives the return from idle. - ~/.config/omarchy/keyboard-backlight.conf sets DARK_LUX, BRIGHT_LUX, IDLE_SECONDS, and POLL_SECONDS. Only whole-number assignments to those keys are read, so the file is settings rather than code, and the shell asks the command for IDLE_SECONDS rather than parsing the file a second time. - Hysteresis on the off edge: once bright light has turned the keys off, they stay off until the room is dark enough for a clearly visible level again instead of flickering at 1-2%. The band is a slice of the ramp, so it follows the configured thresholds. The test drives the real loop against a fake sensor and LED, with long polls so every change is the signal path doing the work. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015BSgNp56iTuhMy7XLHsRC2
81cbf1f to
7cdcbc8
Compare
|
The feature itself is well tested. ARM CI is failing on shared Hyprtoolkit recipe drift (0.5.4-6 installed, 0.5.4-5.1 expected); align the recipe pin, declare the settings-unit packaging dependency, and rerun. |
Summary
Follow-up to #303, as proposed in the review thread here: this extends the merged ambient light loop rather than replacing it. Three additions, all inside the existing command, which stays the one writer of the LED.
--idleand--activerecord the idle state under$XDG_RUNTIME_DIRand prod the loop withUSR1, so the keys go dark the moment the compositor reportsIDLE_SECONDSwithout a key press or trackpad touch, and come back at the first input. A new first-party service,omarchy.keyboard-backlight(shell/plugins/services/keyboard-backlight/), relays the shell'sIdleMonitorinto those two calls. No new systemd unit. A level set by hand while idle survives the return from idle, and a fast idle → active flip while a call is still running is re-sent rather than dropped.~/.config/omarchy/keyboard-backlight.confsetsDARK_LUX,BRIGHT_LUX,IDLE_SECONDS, andPOLL_SECONDS. Only whole-number assignments to those keys are read, so the file is settings rather than code. The shell asks the command for--idle-secondsinstead of parsing the file a second time.Also from the review: the
*kbd_backlight*glob andfind_alsname filter are #303's, the manual override now uses #303's pause behaviour, the QML no longer parses the config itself, andrun()can no longer overwrite a running process's command.authorstaysOmarchyto match the other first-party service manifests.Testing
test/shell.d/brightness-keyboard-auto-test.shkeeps every existing assertion (now under a private$HOME, so a developer's own conf cannot leak into the defaults) and adds config parsing, the fallback for an inverted threshold pair, and a run of the real loop against a fake sensor and LED with a long poll, so every change is the signal path doing the work: idle off, wake, bright-room off, hysteresis just under the threshold, relight, and a hand-set level surviving idle../test/shell: all pass except the two pre-existingomarchy-pkgscheckout tests../test/clipasses,omarchy commands --checkis clean at 458.apple,j493, Hyprland 0.56.2, omarchy 4.0.2-2): loop run from the checkout against the real sensor and LED, service loaded as a plugin. Keys lit at 22 lux, went dark 10 s after the last input, came back on the first touch, repeatedly;--idle/--activefrom a terminal switch the LED within a second.Note: on 4.0.2-2 the unit itself never reaches
/usr/lib/systemd/user/on aarch64 (upstream'somarchy-settingsPKGBUILD installs user units from a fixed list), so the migration's wants symlink dangles and the loop does not run on updated Macs. That is a packaging fix in a separate PR.🤖 Generated with Claude Code
https://claude.ai/code/session_015BSgNp56iTuhMy7XLHsRC2