Screen brightness control utility for at least Thinkpad T490
This is Free software under the MIT license.
- Linux
notify-send
and a notification daemon- Python 3.10
git clone [email protected]:fxjung/backlight_utility.git
cd backlight_utility
pip install -e .[dev]
pre-commit install
Then create a .env
file containing the paths to the respective files:
BRIGHTNESS_PATH=/sys/class/backlight/intel_backlight/brightness
MAX_BRIGHTNESS_PATH=/sys/class/backlight/intel_backlight/max_brightness
ACTUAL_BRIGHTNESS_PATH=/sys/class/backlight/intel_backlight/actual_brightness
Keep in mind that the brightness path needs to be writable by the user running this software.
This can e.g. be achieved by means of a udev rule (/etc/udev/rules.d/99-backlight.rules
):
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/intel_backlight/brightness", RUN+="/bin/chmod g+w /sys/class/backlight/intel_backlight/brightness"
Apparently, directly using udev's MODE
and GROUP
doesn't work here for some reason. The above does.
This can e.g. be used to control the screen brightness via i3wm keyboard shortcuts by modifying ~/.i3/config
:
bindsym XF86MonBrightnessDown exec --no-startup-id "backlight_utility set --relative --notification relative -- -10"
bindsym XF86MonBrightnessUp exec --no-startup-id "backlight_utility set --relative --notification relative -- 10"
The CLI interface offers the following commands:
backlight_utility get
backlight_utility set
to set and retrieve the current brightness. Help is available accordingly:
backlight_utility get --help
backlight_utility set --help
backlight_utility get
backlight_utility set -- -50
backlight_utility set --absolute --value --notification absolute 1000