Intelligent keyboard backlight daemon for Linux laptops with automatic brightness control based on idle time, video playback, power state, WiFi location, and time schedules

Intelligent keyboard backlight daemon for Linux laptops with automatic brightness control based on idle time, video playback, power state, WiFi location, and time schedules.
yay -S kbd-backlight
# or
paru -S kbd-backlight
Requirements:
Debian/Ubuntu:
sudo apt install build-essential libdbus-1-dev libwayland-dev libx11-dev libxss-dev
Arch Linux:
sudo pacman -S base-devel dbus wayland libx11 libxss
Build and install:
git clone https://github.com/ayushjaipuriyar/kbd-backlight.git
cd kbd-backlight
cargo build --release
sudo cp target/release/kbd-backlight /usr/local/bin/
sudo cp target/release/kbd-backlight-daemon /usr/local/bin/
sudo cp kbd-backlight-daemon.service /usr/lib/systemd/user/
Enable the service:
systemctl --user enable --now kbd-backlight-daemon
# Check status
kbd-backlight status
# List available profiles
kbd-backlight list
# Switch profile
kbd-backlight profile office
# Set manual brightness (0-3, depending on your hardware)
kbd-backlight set 2
# Resume automatic control
kbd-backlight auto
# Add time schedule
kbd-backlight schedule add home 22:00 0
Configuration files are stored in ~/.config/kbd-backlight/:
~/.config/kbd-backlight/
├── config.toml # Global settings
├── state.toml # Active profile (auto-managed)
└── profiles/ # Profile definitions
├── home.toml
├── office.toml
└── mobile.toml
Example profile (~/.config/kbd-backlight/profiles/home.toml):
name = "home"
idle_timeout = 30
video_detection_enabled = true
ac_always_on = false
wifi_networks = [
"HomeWiFi",
"HomeWiFi_5GHz"
]
[[time_schedules]]
hour = 9
minute = 0
brightness = 1
[[time_schedules]]
hour = 22
minute = 0
brightness = 0
config.toml)auto_switch_location - Enable automatic profile switching based on WiFiname - Profile identifier (must match filename)idle_timeout - Seconds of inactivity before turning off backlightvideo_detection_enabled - Use MPRIS to detect video playbackac_always_on - Keep backlight on when connected to AC powerwifi_networks - WiFi SSIDs that trigger this profiletime_schedules - Time-based brightness rulesThe daemon monitors multiple inputs and applies rules in priority order:
ext-idle-notify-v1 protocolXScreenSaver extensiongrep idle_timeout ~/.config/kbd-backlight/profiles/*.tomlsystemctl --user status kbd-backlight-daemonjournalctl --user -u kbd-backlight-daemon -fauto_switch_location = true in config.tomlbusctl --user list | grep mprisvideo_detection_enabled = false in profileEnsure your user has access to /sys/class/leds/platform::kbd_backlight/:
sudo usermod -aG input $USER
# Log out and back in
See CONTRIBUTING.md for development setup and guidelines.
This project uses Conventional Commits and automated semantic versioning. Commit messages must follow the format:
<type>(<scope>): <subject>
<body>
<footer>
Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
Examples:
feat: add WiFi-based profile switchingfix: resolve file descriptor leak in idle detectiondocs: update installation instructionsfeat!: change config file format (breaking change)MIT License - see LICENSE for details.
## What's Changed * chore(deps): bump actions/upload-artifact from 3 to 5 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/1 * chore(deps): bump actions/download-artifact from 4 to 6 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/2 * chore(deps): bump actions/setup-node from 4 to 6 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/4 * chore(deps): bump thiserror from 1.0.69 to 2.0.17 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/3 * chore(deps): bump KSXGitHub/github-actions-deploy-aur from 2.7.0 to 4.1.1 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/5 * chore(deps): bump actions/checkout from 4 to 6 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/7 * chore(deps-dev): bump @semantic-release/github from 9.2.6 to 12.0.2 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/10 * chore(deps): bump zbus from 4.4.0 to 5.12.0 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/9 * chore(deps): bump toml from 0.8.23 to 0.9.8 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/8 * chore(deps): bump nix from 0.27.1 to 0.29.0 by @dependabot[bot] in https://github.com/ayushjaipuriyar/kbd-backlight/pull/6 ## New Contributors * @dependabot[bot] made their first contribution in https://github.com/ayushjaipuriyar/kbd-backlight/pull/1 **Full Changelog**: https://github.com/ayushjaipuriyar/kbd-backlight/commits/v1.0.0