Skip to content

feat(lighting): make the toggle turn the LEDs off and let the logo show battery - #18

Merged
vdemonchy merged 1 commit into
mainfrom
feat/lighting-toggle-and-battery-logo
Aug 2, 2026
Merged

vdemonchy merged 1 commit into
mainfrom
feat/lighting-toggle-and-battery-logo

Conversation

@vdemonchy

Copy link
Copy Markdown
Owner

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 rgb block now, carrying an enabled flag. A config.json with no rgb block 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.json as level_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. 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 committed only after every frame is written, so a partial write retries the whole sequence.

config.RGB gains enabled (a *bool, so a config written before this key existed still counts as enabled), battery_logo, level_high and level_low.

Incidental fix

Adding rgb_battery_logo surfaced a config-loading bug in the COSMIC applet: 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. 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

  • New rgbFrames tests cover the delta writes, the disabled-blanking, the threshold mapping, the unknown-level fallback and the missing-enabled back-compat path. Go suite and the applet's cargo test pass.
  • Installed on a live COSMIC session: config.json round-trips through the new shape with the saved settings intact.
  • Confirmed on the controller in XInput mode — toggling off blanks the zones, toggling on restores them, and the logo tracks the battery band.

GNOME and KDE carry the same two options and the same gating, but were not exercised on a live session.

🤖 Generated with Claude Code

…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>
@github-actions github-actions Bot added the enhancement New feature or request label Aug 2, 2026
@vdemonchy
vdemonchy merged commit 3ea3249 into main Aug 2, 2026
1 check passed
@vdemonchy
vdemonchy deleted the feat/lighting-toggle-and-battery-logo branch August 2, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant