Configuring brightness keys in i3wm

I have a Dell XPS 13 9360, and I have just started using i3wm. Installing Ubuntu and i3 was easy enough following the tutorial on i3wm’s website. One of the hard parts was getting the brightness keys to work. Going around the web, most of the solutions offered involve using xbacklight to control the brightness and binding it with the correct keys by copying the following snippet into the config file (located in ~/.config/i3/config):

# Screen brightness controls
# increase screen brightness
bindsym XF86MonBrightnessUp exec xbacklight -inc 20
# decrease screen brightness
bindsym XF86MonBrightnessDown exec xbacklight -dec 20

Initially, I didn’t have xbacklight installed, and when I installed it running xbacklight -dec 20 did nothing. The only message I got was that No outputs have backlight property.

I found this Stackoverflow question that detailed my problem, but the accepted answer of making a symbolic link just didn’t work. I was always getting ln: failed to create symbolic link '/sys/class/backlight/brightness': Operation not permitted.

Thankfully I found the answer in this blogpost.

I cloned light into ~/.light and installed with sudo make && sudo make install.

$ git clone https://github.com/haikarainen/light.get ~/.light
$ cd .light
$ sudo make # you might need to install make and gcc
$ sudo make install

And finally I was able to add the snippet below to my config and control brightness. Don’t forget to reload your config with mod+Shift+c!

# Screen brightness controls
# increase screen brightness
bindsym XF86MonBrightnessUp exec light -A 5
# decrease screen brightness
bindsym XF86MonBrightnessDown exec light -U 5

Hope this helps!

Thanks for reading, Jose :)

Comments