I got a new laptop – Thinkpad t480s – it is a great machine!
But since I like to use i3wm for my work, there was a bit of a problem with the way I control the brightness on my old machine. I had two scripts which were triggering when I press the function keys which were detected as
The problem is that this newer machine was not detecting these keys with
xev and when I was using the function keys for the screen brightness acpi events were triggered, so I needed to find how to catch the key presses.
So bellow is what I used in order to control my brightness.
First of all you need to find out what keys acpi detects, you can do that with
In my case the output of it was the keys
video/brightnessup BRTUP 00000086 00000000
video/brightnessdown BRTDN 00000087 00000000
So the next step is to add new acpi event. This is very straightforward, for ubuntu you just go to the
/etc/acpi/events/ folder and create two files there – one for increasing the brightness and one for decreasing it. What you put in these files is simply what command or script to be executed when that key is pressed. I will give example with just the brightness increase scripts, as the brightness decrease are basically the same, just the key and script is different, so you should not have any problems adding the others.
/etc/acpi/events/brightness_up looks like this
# /etc/acpi/events/brightness_up # This is called when the user presses the brightness up button and calls # /home/ivan/.config/i3/brightness_up.sh which will increase the screen brightness. # Author: Ivan Denkov event=video/brightnessup BRTUP 00000086 00000000 action=/etc/acpi/brightness_up.sh
This trigger the script located in
/etc/acpi/brightness_up.sh you need to make that script executable, and this are the contents to go there. Here is the script:
#!/bin/bash CAT="$(which cat)" current_brightness=`$CAT /sys/class/backlight/intel_backlight/brightness` new_brightness=$(($current_brightness+20)) echo $new_brightness > /sys/class/backlight/intel_backlight/brightness
You just need to replicate the event and the script for lowering the brightness and you should be good to go.
If for some reason the above does not work, make sure that:
– You have made the bash scripts executable.
– Make sure the bash scripts by itself can change the brightness(It is actually working)
– Double check
acpi_listen to make sure you have put the correct keys in the events.