No description
  • Rust 96.3%
  • Just 2.7%
  • Fluent 1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Claude ed39f703e8 Serialise HID access and reminders across applet instances
The panel runs one applet process per output. Concurrent copies were
corrupting each other's HID replies, making devices vanish, and each sent
its own duplicate notification.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 16:43:46 +02:00
i18n/en Localise the interface and document data-source limits 2026-07-26 16:40:39 +02:00
res Scaffold applet crate, packaging, and docs 2026-07-26 15:57:31 +02:00
src Serialise HID access and reminders across applet instances 2026-07-26 16:43:46 +02:00
.gitignore Scaffold applet crate, packaging, and docs 2026-07-26 15:57:31 +02:00
Cargo.lock Localise the interface and document data-source limits 2026-07-26 16:40:39 +02:00
Cargo.toml Localise the interface and document data-source limits 2026-07-26 16:40:39 +02:00
i18n.toml Localise the interface and document data-source limits 2026-07-26 16:40:39 +02:00
justfile Scaffold applet crate, packaging, and docs 2026-07-26 15:57:31 +02:00
LICENSE Scaffold applet crate, packaging, and docs 2026-07-26 15:57:31 +02:00
README.md Localise the interface and document data-source limits 2026-07-26 16:40:39 +02:00

COSMIC Advanced Power Applet

A COSMIC panel applet that monitors the battery of every device attached to the computer, not just the system power supply.

COSMIC's stock battery applet covers power profiles, screen brightness and the laptop battery. It has nothing to say about the Bluetooth headset, the wireless mouse, the controller or the UPS — and on a desktop with no internal battery it is close to inert. This applet fills that gap.

What it does

  • One capsule, one segment per device. The panel shows a single rounded capsule divided into segments, each filled in proportion to that device's charge. No numerals, no icon that has to pick a winner among several devices.
  • Immediate visual warning. Any device below the low threshold recolours its segment to the theme's warning accent, and to the destructive accent below the critical threshold.
  • Charging reminders. A notification fires when a device drops below the threshold and repeats at a configurable interval until it is charged. Repeats replace the previous notification rather than stacking.
  • Click for detail. The popup lists every device with its name, charge and charging state, plus the settings.

Device discovery

Source Covers
UPower Laptop batteries, UPS units, Bluetooth devices, and HID devices with a kernel power_supply (Logitech, Sony, Steam, …)
BlueZ org.bluez.Battery1 Bluetooth devices on systems where UPower's BlueZ integration is unavailable. De-duplicated against UPower by MAC
HID Vendor devices the kernel exposes no battery for. Currently Razer, read directly from hidraw

OpenRazer is deliberately not a dependency — requiring an out-of-tree DKMS kernel module would defeat the goal of working on any distribution.

Requirements

  • COSMIC desktop
  • upower (present on essentially every desktop Linux install)
  • bluez — optional, only for the BlueZ fallback
  • A Rust toolchain and just to build

Install

just build-release
sudo just install

To install into a user prefix instead:

just build-release
just install prefix=~/.local

A user-prefix install skips the udev rule, since that needs root. Without it, HID-only devices such as Razer mice cannot be read and simply will not appear; the applet keeps working for everything else. To add the rule afterwards:

sudo install -Dm0644 res/99-cosmic-advanced-power.rules /usr/lib/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

The rule uses TAG+="uaccess", which has systemd-logind grant the seat's active user an ACL on the device node — no group membership and no root at runtime.

Then add the applet in Settings → Desktop → Panel → Configure panel applets.

Settings

Click the capsule and open Settings in the popup: the low and critical thresholds, how often a low device is announced again, whether to keep reminding while a device charges, and which devices appear in the panel.

Troubleshooting

To see what the applet detects without involving the panel at all:

just dump

This enumerates every device each backend finds, along with the source it came from, and exits. If a device is missing here it will be missing in the panel.

Note that a HID device answers one program at a time. Running just dump while the applet is in the panel makes the two contend for the device, and either may report a garbled reply; quit one before trusting the other.

A Bluetooth device shows an old percentage

Bluetooth peripherals push a battery level only when they choose to — typically on connect and then rarely. Plugging one in to charge usually sends no update at all, so the percentage can sit unchanged for hours and there is no way to ask for a fresh one. org.bluez.Battery1 also carries no charging state, which is why such devices show no "Charging" label.

The popup shows a reading's age once it passes half an hour, so you can tell a stale number from a wrong one. Reconnecting the device is the reliable way to force a fresh reading.

A device is missing entirely

Check just dump first. If the device appears under no source, nothing on the system is reporting its battery — for HID devices, the usual cause is the udev rule not being installed (see above).

License

GPL-3.0-only