- Rust 75.2%
- JavaScript 17.5%
- Shell 5.9%
- Makefile 1.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
Build & Release / build-and-release (push) Successful in 3m10s
Reviewed-on: #4 |
||
| .forgejo/workflows | ||
| scripts | ||
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| install.sh | ||
| kde-plasma-framework-keyboard-brightness.modules-load.conf | ||
| kde-plasma-framework-keyboard-brightness.service | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
KDE Plasma Framework Keyboard Brightness
A native Linux bridge that makes the Framework Laptop 16 keyboard/numpad backlight available to KDE Plasma's Brightness and Color widget.
The Framework keyboard/numpad runs QMK and exposes brightness through the VIA raw-HID protocol rather than the standard Linux LED interface. This daemon creates a virtual framework::kbd_backlight LED with the kernel's uleds driver and translates brightness changes in both directions.
How it works
- Discovers a supported Framework Laptop 16 keyboard by USB vendor/product ID and verifies its QMK raw-HID report descriptor.
- Reads and writes brightness with VIA's QMK backlight channel.
- Registers
/sys/class/leds/framework::kbd_backlightwith brightness range0..255. - Plasma and UPower see that device as a normal keyboard backlight.
- Polls the modules so brightness changes made with
Fn+Space, are reflected in Plasma. - Turns off the backlight breathing effect whenever a module reports it, for example after the breathing toggle key was pressed.
Hardware changes are also published through UPower's D-Bus API so Plasma receives brightness-change notifications. The virtual uleds device cannot emit the kernel's brightness_hw_changed event, so updating sysfs alone is not sufficient. Notifications are retried if UPower is starting or restarting, and newer slider/key changes supersede pending notifications. On older UPower versions without per-keyboard enumeration, notifications are sent only when this is the sole keyboard backlight LED.
When this is the sole keyboard backlight, both UPower's per-device and legacy/composite interfaces are notified. With multiple keyboard backlights, only the Framework device is updated: UPower's composite setter would change all of them. Older Plasma versions that listen only to the composite interface may therefore not refresh their slider for hardware changes in that multi-keyboard setup.
Polling runs even during continuous slider updates. VIA transactions discard queued replies and wait for a matching response (including the exact value for writes), so another VIA client's unrelated packets do not trigger a reconnect. VIA has no transaction IDs: concurrent clients issuing identical requests cannot be distinguished, and clients that actively change brightness still share control of the hardware.
Polling also reapplies the reported brightness using volatile writes. This corrects wake/unlock cases where the physical backlight turns on even though QMK and Plasma still report the previous level (including 0%).
After system suspend, the daemon restores its pre-suspend target before processing queued brightness events or polling the hardware. This also handles firmware that resets its reported level on wake, which would otherwise be mistaken for a brightness-key change. Resume detection compares Linux's suspend-aware boot clock with its monotonic clock; it is independent of wall-clock changes and does not require a desktop session. The service journal records resume restorations, hardware-reported level changes, and virtual-LED requests to help distinguish firmware resets from desktop writes.
Plasma shows a single keyboard backlight slider, so the keyboard and the numpad share it: the slider sets both, and a brightness change on one module is copied to the other. At startup the numpad takes over the keyboard's brightness. Modules attached or detached while the daemon runs are picked up within a few seconds.
Supported modules:
| Module | USB ID |
|---|---|
| ANSI keyboard | 32ac:0012 |
| ISO keyboard | 32ac:0018 |
| JIS keyboard | 32ac:0019 |
| Numpad | 32ac:0014 |
Requirements
- Framework Laptop 16 keyboard and/or numpad module with stock QMK/VIA-compatible firmware
- Linux kernel with
CONFIG_LEDS_USER/theuledsmodule - KDE Plasma and UPower
- A system D-Bus (used to notify UPower about hardware brightness changes)
- Rust toolchain, GCC, Make, and
pkg-configto build sudoaccess to install the system service
Install
From a release (recommended)
On Linux x86-64 or ARM64, install the latest stable release without Git, Rust, or Make:
curl -fsSL https://git.nmm.ee/asko/plasma-fw-kb-brightness/raw/branch/master/install.sh | sh
The installer requires curl, tar with gzip support, sha256sum, standard Linux utilities, systemd, and modprobe. It downloads the architecture-specific archive, verifies its SHA-256 checksum, installs the executable and service configuration, loads uleds, and enables/restarts the service. It uses sudo for installation unless already running as root. Checksums detect corruption; they are not independent signatures of the release.
To inspect the script first or install a specific version:
curl -fsSL https://git.nmm.ee/asko/plasma-fw-kb-brightness/raw/branch/master/install.sh -o install.sh
# Review install.sh before running it.
sh install.sh v0.1.0
Rerun the installer to upgrade. Release archives contain statically linked musl executables, the systemd service, module-load configuration, and license. The same Framework hardware, kernel, and Plasma requirements still apply; an ARM64 build does not imply support for other keyboard hardware.
Build from source
After cloning this repository:
make install
This builds the release binary, installs it to /usr/local/bin, loads uleds, and enables the system service immediately. Log out and back in, or restart PowerDevil, if Plasma does not refresh the slider automatically.
Check status
systemctl status kde-plasma-framework-keyboard-brightness.service
journalctl -u kde-plasma-framework-keyboard-brightness.service -f
The virtual device should report a valid range:
cat /sys/class/leds/framework::kbd_backlight/max_brightness
cat /sys/class/leds/framework::kbd_backlight/brightness
Uninstall
make uninstall
The virtual LED disappears when the service stops. The uninstall target removes the binary, service, and module-load configuration. It does not unload uleds, because another process may be using it; the unused module will disappear after reboot.
If you installed from a release and have no checkout:
sudo systemctl disable --now kde-plasma-framework-keyboard-brightness.service
sudo rm -f /usr/local/bin/kde-plasma-framework-keyboard-brightness \
/etc/systemd/system/kde-plasma-framework-keyboard-brightness.service \
/etc/modules-load.d/kde-plasma-framework-keyboard-brightness.conf
sudo systemctl daemon-reload
Development
cargo test
cargo build
make build
node --test tests/*.test.mjs
The Rust tests include HID packet-exchange regressions and a mock UPower service on a private D-Bus; install dbus-daemon to run them. They do not require root or access to the real keyboard, virtual LED, or system bus.
Running the daemon manually requires root because Fedora restricts /dev/uleds and /dev/hidraw*:
sudo target/debug/kde-plasma-framework-keyboard-brightness
Safety
- The daemon accepts only Framework's keyboard USB IDs and the exact QMK raw-HID descriptor.
- Brightness updates are volatile VIA commands, avoiding EEPROM writes and flash wear while dragging the slider.
- The systemd service restricts device access to
uledsand hidraw and applies filesystem and process hardening. - No keyboard firmware modification is required.
Contribution
You can send patches to asko@nmm.ee.
License
MIT