A lightweight, automated background service for Linux that intelligently manages your laptop's keyboard backlight to save battery.
It automatically turns off the keyboard backlight after a set period of inactivity and instantly restores it when you resume typing or moving the mouse.
Designed for: It is specifically designed for Debian-based distributions (like Ubuntu, Linux Mint, Pop!_OS, Kali, etc.). Specialized Support: Includes specific fixes for ASUS TUF / ROG gaming laptops where LED permissions reset on reboot.
- ⚡ Smart Auto-Off: Turns off keyboard LEDs after 15 seconds (customizable) of inactivity.
- 💡 Instant Wake: Lights turn back on immediately upon keypress or mouse movement.
- 🐧 Universal Compatibility: Works on both Wayland (GNOME Modern) and X11 sessions.
- 🛡️ Permission Fixer: Includes a systemd service to permanently fix "Permission Denied" errors on strict hardware (like ASUS TUF series).
- 🔋 Battery Efficient: Uses minimal resources (sleep-based monitoring).
You can install this tool with a single command using the included installer script.
-
Clone the repository:
git clone https://github.com/mclovin22117/linux-auto-kbd-backlight.git cd linux-auto-kbd-backlight -
Run the installer:
chmod +x install.sh ./install.sh
The installer will ask for your
sudopassword to set up the permission-fix service. -
That's it! Wait 15 seconds without touching your mouse or keyboard to test it.
The default timeout is set to 15 seconds. To change this:
-
Edit the installed script:
nano ~/.local/bin/kbd-auto-off -
Change the
TIMEOUTvariable at the top of the file:# Configuration TIMEOUT=60 # Change this to your desired seconds
-
Restart the service to apply changes:
systemctl --user restart kbd-backlight
- Check the service status:
systemctl --user status kbd-backlight
- Check for activity detection:
Run the script manually to see what it detects:
If it says "Monitoring..." but never "Turning off," your laptop might be sending "ghost" signals.
~/.local/bin/kbd-auto-off
If your lights don't change, the permission fixer might not have triggered for your specific device path.
- Run this command to force permissions manually:
sudo chmod 666 /sys/class/leds/*kbd_backlight*/brightness
- If this works, ensure the
kbd-brightness-fix.serviceis enabled:systemctl status kbd-brightness-fix
To completely remove the tool and services:
-
Stop and remove the user service:
systemctl --user stop kbd-backlight systemctl --user disable kbd-backlight rm ~/.config/systemd/user/kbd-backlight.service -
Remove the system permission fixer:
sudo systemctl stop kbd-brightness-fix sudo systemctl disable kbd-brightness-fix sudo rm /etc/systemd/system/kbd-brightness-fix.service
-
Delete the script:
rm ~/.local/bin/kbd-auto-off
Pull requests are welcome! If you have a different laptop model (Dell, Lenovo, HP) that requires a specific path in find_backlight_path(), please feel free to open an issue or submit a PR.
This project is licensed under the MIT License