Ubuntu – How to adjust the screen brightness in i3wm on Ubuntu 16.04

brightnessi3-wmshortcut-keys

I'm running Ubuntu 16.04 on a System76 laptop. The brightness controls (i.e. Fn+F8 and Fn+F9) work great in Unity/Compiz/Gnome/whatever is default, but when I change to using i3wm instead I get… nothing.

Under the default, xev reports something different. With i3 it reports XF86MonBrightnessUp and XF86MonBrightnessDown, which would be pretty cool if xbacklight worked, but it doesn't. It just has zero effect.

wayne@waynego:~$ xbacklight -set 10
wayne@waynego:~$ echo $?
0

And my monitor is still as bright/dark as it was before.

The only thing that I've been able to get to work is this:

sudo sh -c "cat /sys/class/backlight/intel_backlight/max_brightness > /sys/class/backlight/intel_backlight/brightness"

Which you can probably agree is not ideal – cause I have to involve sudo, I mean I could gksudo or something but that's annoying, too. Clearly something works right with compiz/unity… I just don't know what it's doing.

Is there some way to get xbacklight to work, or some alternative? I'd prefer not to have to run sudo to change my backlight settings.

Best Answer

Following the instructions that I found on https://itsfoss.com/fix-brightness-ubuntu-1310/ combined with what I already knew, that I had an Intel card, I did

sudo touch /usr/share/X11/xorg.conf.d/20-intel.conf
sudoedit /usr/share/X11/xorg.conf.d/20-intel.conf

In that file I put the following:

Section "Device"
        Identifier  "card0"
        Driver      "intel"
        Option      "Backlight"  "intel_backlight"
        BusID       "PCI:0:2:0"
EndSection

And now I can use xbacklight, as mreq mentions:

I added the following to my ~/.config/i3/config

bindsym XF86MonBrightnessUp exec xbacklight -inc 10
bindsym XF86MonBrightnessDown exec xbacklight -dec 10

The best part here is that I can actually turn my backlight all the way off, so if I wanted to use my computer as a dream journal like Adam Savage does, I totally could.