Sunday, 15 March 2020

Setting up brightness control

While most of the important functions of my keyboard like volume control worked out of the box even with animated Task Bar Panel Item there was one that after a while become painfully missing and this was brightness control. As brightness control works automatic under Windows it took me quite some time and even some tears to realize it does not work on Debian with Raspberry Pi Desktop (RPD from now on). As I found only resolution settings in Preferences > Screen Configuration that I already mentioned in the previous post I had to look for some other ways to make brightness control work. Searching on the topic the first hint was that brightness aka back light is not governed by ACPI on my laptop but it is Intel specific:

pi@raspberrypi:~ $ ls -la /sys/class/backlight/
total 0
drwxr-xr-x  2 root root 0 Mar 15 09:05 .
drwxr-xr-x 55 root root 0 Mar 15 09:05 ..
lrwxrwxrwx  1 root root 0 Mar 15 09:05 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight
pi@raspberrypi:~ $ 

And indeed I could change brightness by simply writing a number between 0 and max_brightness:

pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# echo 100 > /sys/class/backlight/intel_backlight/brightness
root@raspberrypi:/home/pi#

For some reason the configuration in /usr/share/X11/xorg.conf.d/20-intel.conf did not give me the usual keyboard controls back on brightness. There were some other hints on using acpi_osi= in grub command line and while it seems to make my brightness control keys working again but it gave me a lot of errors during boot and I could not figure out which of the numerous grub application I should use to update grub command line for persistence. I was not in favor risking to break boot of my laptop now as at the time of writing this blog we suffer from the most serious pandemic in my life the corona virus outbreak. Basically we are asked to self isolate so my laptop has become an even more important piece to be able to keep working.

But there are a few nice little applications that can be installed from Preferences > Add / Remove Software that make my brightness control keys working again. The first is xbacklight that can increase and decrease brightness in steps. In order to make it work on my laptop I had to add this configuration:

pi@raspberrypi:~ $ more /etc/X11/xorg.conf
Section "Device"
Identifier "Card0"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection
pi@raspberrypi:~ $

The other app is xbindkeys that can bind this brightness control back to my Fn F5 and Fn F6 keys by adding this to ~/.xbindkeysrc:

#BrightnessDown
"xbacklight -10"
    m:0x0 + c:232
    XF86MonBrightnessDown

#BrightnessUp
"xbacklight +10"
    m:0x0 + c:233
    XF86MonBrightnessUp


I have arrived to this config using xbindkeys-config with the Get Key pop up that might come useful to create other hot keys also.

After this starting xbindkeys has put my brightness control keys back in action even after reboot.


No comments:

Post a Comment