Skip to content

feat: hotkey-only brightness OSD + battery AC plug/unplug indicator#194

Open
jibsta210 wants to merge 1 commit into
pop-os:masterfrom
jibsta210:feat/lilypad-patches
Open

feat: hotkey-only brightness OSD + battery AC plug/unplug indicator#194
jibsta210 wants to merge 1 commit into
pop-os:masterfrom
jibsta210:feat/lilypad-patches

Conversation

@jibsta210
Copy link
Copy Markdown

Summary

Two related additions to the OSD daemon:

  • Hotkey-only brightness OSD — subscribes to a new DisplayBrightnessHotkey D-Bus signal from cosmic-settings-daemon (feat: Action::Snap variant + DisplayBrightnessHotkey signal cosmic-settings-daemon#144) so the brightness slider only appears when the user actually pressed a brightness key. The default property-change subscription fires on every backlight write, including programmatic ones (dim-on-idle, accessibility tooling, screen savers), which currently makes the OSD pop up every time the screen is about to sleep. This PR keeps the existing property subscription, but adds the hotkey signal as the canonical user-facing trigger so the OSD can suppress noisy programmatic writes cleanly when paired with that daemon change.
  • Battery AC plug/unplug indicator — a small status pill that appears when the AC adapter is connected/disconnected, showing the current battery percentage and charging state. Uses the standard UPower interface; new BatteryStatus subscription on the app side, new Params::BatteryStatus(percentage, charging, plugged) variant in osd_indicator that maps to the appropriate battery-*-symbolic icon and renders the percentage value.

Motivation

  • Hotkey signal: paired with the cosmic-idle dim-on-idle PR (pop-os/cosmic-idle), the brightness OSD currently flashes once per fade frame as the backlight is being lowered. There's no clean way today for the OSD to tell who wrote the value. A separate signal for the user-facing path solves this without changing existing behaviour for clients that don't subscribe to it.
  • Battery indicator: nice ergonomic touch — gives feedback when you plug/unplug a laptop charger without needing to glance at the panel. Mirrors the volume/brightness OSD pattern.

Implementation

  • src/components/app.rs:
    • Msg::HotkeyBrightness(u32) and a hotkey_brightness_subscription that listens for the new daemon signal.
    • Msg::BatteryStatus { percentage, charging, plugged } and a battery_status_subscription that watches UPower's org.freedesktop.UPower.Device properties for state / percentage changes on the primary display device.
  • src/components/osd_indicator.rs:
    • New Params::BatteryStatus(percentage, charging, plugged) variant.
    • Icon selection: battery-{level}{-charging}-symbolic based on percentage bucket and charging flag, falling back to the symbolic family already used for volume/brightness.

Testing

Daily-driven for several weeks. Hotkey signal verified by tapping the brightness keys vs. running a backlight fader programmatically — only the former pops the OSD. Battery indicator verified by plugging/unplugging the charger.

Dependencies

The hotkey path requires pop-os/cosmic-settings-daemon#144. The battery indicator is independent — happy to split that into a separate PR if maintainers prefer to review them apart.

AI Disclosure

Patches were drafted with assistance from Claude (Anthropic). Commits include Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> trailers. I understand each change and will respond to review feedback. I'm aware of the AI-PR policy in the template — happy to rework or close if maintainers prefer.

  • I have disclosed use of any AI generated code in my commit messages.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

… indicator

Three additions to the OSD daemon, batched on a single branch I daily-drive:

* **Hotkey-only brightness OSD.** Subscribes to the new
  `DisplayBrightnessHotkey` D-Bus signal from cosmic-settings-daemon
  (companion daemon patch) so the brightness slider only appears on
  hotkey-driven changes — not on every property write. Fixes the dim-on-idle
  fade flashing the OSD on every frame. The listener also fetches
  `MaxDisplayBrightness` on connect and pairs it with each signal, so the
  OSD doesn't depend on a separately-arriving property subscription having
  populated `max` first (without that, the OSD silently no-ops if the
  hotkey signal arrives before the property subscription does).

* **Device-aware volume OSD icon.** Picks `audio-headphones-symbolic`
  instead of the generic speaker family when the default sink is
  Bluetooth (`bluez_output.*` / `bluez_sink.*`) or wired headphones (alsa
  node name containing `headphone`). Previous behaviour showed a speaker
  silhouette regardless of where audio was actually going. Mute always
  shows `audio-volume-muted-symbolic` for clarity. Sink classification
  uses the default-sink name from the existing pulse subscription —
  no additional D-Bus / pulse calls.

* **Battery AC plug/unplug indicator.** Status pill on AC connect/disconnect
  showing battery percentage and charge state. Uses UPower; new
  `BatteryStatus` subscription + `Params::BatteryStatus(percentage,
  on_battery, charging)` variant in `osd_indicator` mapping to the
  appropriate `battery-*-symbolic` icon.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jibsta210 jibsta210 force-pushed the feat/lilypad-patches branch from e5e7156 to a2321da Compare May 20, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant