Repository navigation
feat(lighting): make the toggle turn the LEDs off and let the logo show battery - #18
Merged
Merged
Conversation
…ow battery Two changes to the controller lighting, across the daemon and all three frontends. - "Control lighting" becomes "Enable lighting", and off now means off. It used to mean "the daemon doesn't touch the LEDs", which left the controller on its firmware animation with no way to stop it from the UI. The frontends now always emit the rgb block and carry an `enabled` flag; when it is false the daemon blanks all four zones. The colour controls only exist while lighting is on — there is nothing to configure when the LEDs are off. A config.json with no rgb block at all still leaves the lighting untouched, so CLI-only setups are unaffected. Note the behaviour change for everyone else: the toggle defaults to off, so the first run after upgrading blanks the LEDs instead of leaving the animation. - New "Logo shows battery level" option hands the Logo zone to the daemon, which colours it green/yellow/red from the battery percentage using the same thresholds that tint the tray icon (now written to config.json as level_high/level_low). The other zones keep their configured colours, and the logo falls back to its configured colour whenever the level is unknown — absent, no battery source, or stale — rather than claiming a level the daemon can't vouch for. The daemon now re-applies lighting on every poll so the logo can track the level. rgbFrames is a delta against what was last pushed: unchanged lighting sends zero frames and never opens the hidraw node, and a battery band change sends exactly one zone write, with no enter-static flash. State is only committed after every frame is written, so a partial write retries the whole sequence. Also fixes an applet config-loading bug this surfaced: cosmic-config's get_entry returns Err when any key is missing from the stored config, and init discarded the partial config that comes back with it. Adding rgb_battery_logo would therefore have reset every saved setting on first launch. The partial config is now kept, so only missing keys fall back to their defaults. Go suite (including new rgbFrames tests for the delta writes, the disabled-blanking, the threshold mapping and the unknown-level fallback) and the applet's cargo tests pass. Installed on a live COSMIC session: config.json round-trips through the new shape with the saved settings intact, and both behaviours confirmed on the controller in XInput mode. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two changes to the controller lighting, across the daemon and all three frontends.
"Control lighting" → "Enable lighting", and off now means off
The toggle used to mean "the daemon doesn't touch the LEDs", which left the controller running its firmware animation with no way to stop it from the UI. It now controls the lighting: on lights the LEDs from the saved settings, off blanks all four zones. The colour controls only exist while lighting is on — there is nothing to configure when the LEDs are off.
The frontends therefore always emit the
rgbblock now, carrying anenabledflag. Aconfig.jsonwith norgbblock at all still leaves the lighting untouched, so CLI-only setups are unaffected.Note
Behaviour change for existing users: the toggle defaults to off, so the first run after upgrading blanks the LEDs instead of leaving the firmware animation running.
New "Logo shows battery level" option
Hands the Logo zone to the daemon, which colours it green / yellow / red from the battery percentage using the same thresholds that tint the tray icon (now written to
config.jsonaslevel_high/level_low). The other three zones keep their configured colours, and the logo falls back to its configured colour whenever the level is unknown — absent, no battery source, or stale — rather than claiming a level the daemon can't vouch for.How
The daemon re-applies lighting on every poll so the logo can track the level.
rgbFramesis a delta against what was last pushed: unchanged lighting sends zero frames and never opens the hidraw node, and a battery band change sends exactly one zone write, with no enter-static flash. State is committed only after every frame is written, so a partial write retries the whole sequence.config.RGBgainsenabled(a*bool, so a config written before this key existed still counts as enabled),battery_logo,level_highandlevel_low.Incidental fix
Adding
rgb_battery_logosurfaced a config-loading bug in the COSMIC applet:cosmic-config'sget_entryreturnsErrwhen any key is missing from the stored config, andinitdiscarded the partial config that comes back with it. Any new key would therefore have reset every saved setting on first launch. The partial config is now kept, so only genuinely missing keys fall back to their defaults.Testing
rgbFramestests cover the delta writes, the disabled-blanking, the threshold mapping, the unknown-level fallback and the missing-enabledback-compat path. Go suite and the applet'scargo testpass.config.jsonround-trips through the new shape with the saved settings intact.GNOME and KDE carry the same two options and the same gating, but were not exercised on a live session.
🤖 Generated with Claude Code