Posted on 10.09.2020
I have recently written a mini-program in C to deal with the backlight problem on my new Thinkpad E15 Gen 2 laptop. It's a simple program that utilizes sysfs to change the backlight so I could use the Fn keys to adjust the laptop's screen brightness again.
I had to create this program since Xbacklight could not detect the backlight property using the RandR extension. I am not sure why Xorg cannot register the backlight property, but this program is the quickest approach to replacing Xbacklight functionality. To eliminate the Xorg overhead, I directly read from and wrote to the file in charge of the brightness value, which seems to be much straightforward than going through the Xorg X server.
As of right now, the source code is hard-coded with AMDGPU configurations. The makefile also directly adds the setuid bit to the compiled binary to work for non-root users. I am hoping to update these parts to make them more configurable.
The link to the source code is provided below. Any constructive comments and suggestions are welcome!