home | whoami
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.
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 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
After restarting ACPI daemon, I've got properly working brightness control keys. Furthermore, it works in both Xorg session and in the TTY consoles.
sudo systemctl restart acpid