tags: linux, xorg, thinkpad, acpi, brightness
After installing i3 window manager, I startded to tune it up.
Shortly I revealed that brightness control keys do not work. After googling awhile I found this answer on the StackExchange.
On Debian/Ubuntu make sure you have acpitool installed:
apt-get install acpitool
Using acpi_listen I’ve found that Fn+F5(XF86MonBrightnessDown) and Fn+F6(XF86MonBrightnessUp) respond for these ACPI events on my laptop:
$ acpi_listen
video/brightnessdown BRTDN 00000087 00000000
video/brightnessup BRTUP 00000086 00000000
So I added following rules:
# /etc/acpi/events/thinkpad-backlight-down
event=video/brightnessdown BRTDN 00000087 00000000
action=/etc/acpi/thinkpad-display-brightness.sh down
# /etc/acpi/events/thinkpad-backlight-up
event=video/brightnessup BRTUP 00000086 00000000
action=/etc/acpi/thinkpad-display-brightness.sh up
and action script /etc/acpi/thinkpad-display-brightness.sh which will be called when approprite event happens:
#!/bin/sh
BASE_DIR=/sys/class/backlight/intel_backlight
test -d $BASE_DIR || exit 0
MIN=50
MAX=$(cat $BASE_DIR/max_brightness)
ACTUAL=$(cat $BASE_DIR/actual_brightness)
if [ "$1" = down ]; then
ACTUAL=$((ACTUAL-100))
else
ACTUAL=$((ACTUAL+100))
fi
if [ "$ACTUAL" -lt $MIN ]; then
ACTUAL=$MIN
elif [ "$ACTUAL" -gt $MAX ]; then
ACTUAL=$MAX
fi
echo $ACTUAL > $BASE_DIR/brightness
chmod +x /etc/acpi/thinkpad-display-brightness.sh
After restarting ACPI daemon, I’ve got properly working brightness control keys.
OS with systemd:
sudo systemctl restart acpid
Slackware:
/etc/rc.d/rc.acpid restart
Furthermore, it works in both Xorg session and in the TTY consoles.
Update 2019-11-15 Update 2022-05-21