I’m very pleased with i3wm, but day by day I need to adjust something. At this time, on my new laptop, the brightness hardware keys don’t work as expected.
The issue on the Lenovo Thinkpad with Fedora 26 is the same on the Acer ES1-111 with Ubuntu 17.04. At the bottom of i3wm, we found respectively the GNOME and the Unity windows manager. On both GNOME3 and Unity7, the hardware brightness keys work fine.
So, the problem is with i3wm only.
*** The following solution is tested by users and it seems working without issues also on Fedora 28, 29, 30 and Ubuntu 18.04, 18.10 and 19.04 ***
Many solutions. Changing the brightness
Looking into the infinite knowledge of Google, I found a lot of solutions.
The issue is set by the xbacklight command and brightness control doesn’t work in i3wm, I tested it and it doesn’t work also from a terminal session. So, the following lines don’t work.
# Screen brightness controls bindsym XF86MonBrightnessUp exec xbacklight -inc 20; # increase screen brightness bindsym XF86MonBrightnessDown exec xbacklight -dec 20; # decrease screen brightness
The most part of the solutions that I found, planned to make some scripts, changing the brightness with some bash commands:
$ sudo echo VALUE > /sys/class/backlight/intel_backlight/brightness
And save the script in some place, maybe in user bin folder or something in your PATH. Then, call the script from your i3wm .config file. To run the script, it needs the superuser (sudo) privileges and so you must just give it to the root user to launch it from the configuration file.
Anyway, I preferred a different approach. I found an alternative to xbacklight command, a GNU/Linux application to control backlights called simply light. You can find light on GitHub.
light is packed only for Arch Linux and you can find only packages for this distribution. Luckily, light is really lightweight and easy-easy to compile on every other distribution.
So, just download or clone the source of light:
$ git clone https://github.com/haikarainen/light.git
Compile and install it:
$ make $ make install
If you are getting permission errors with
make install check and see whether you are trying to install into system directories. With
sudo make install, you can install the files in directories which are otherwise read-only to your user.
On Fedora 26/27 and Ubuntu 16.04-18.04 all went fine. You can check it:
$ light --help
And, finally, replace the lines of code in the i3wm .config file:
# Screen brightness controls # bindsym XF86MonBrightnessUp exec xbacklight -inc 20; # increase screen brightness # bindsym XF86MonBrightnessDown exec xbacklight -dec 20; # decrease screen brightness bindsym XF86MonBrightnessUp exec light -A 5; # increase screen brightness bindsym XF86MonBrightnessDown exec light -U 5; # decrease screen brightness
Thanks to a user request in comments, if you also want to add notifications for brightness changing, you can do this:
# Screen brightness controls with notification bindsym XF86MonBrightnessUp exec "light -A 5; notify-send 'brightness up'"; # increase screen brightness with notification bindsym XF86MonBrightnessDown exec "light -U 5; notify-send 'brightness down'"; # decrease screen brightness with notification
And now the brightness control doesn’t work in i3wm issue is went away, enjoy it!