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!
*** Fedora Update – Thanks to Eduard Lucena ***
Now, light is packaged in the official Fedora 29/30 repositories, so to install it on
$ sudo dnf install light
So your problem was with xbacklight not with i3wm.
I think you should rename your title to reflect that fact, it’s nothing to do with i3wm and anyone using other window manager eg fluxbox could be affected in the same way.
Thanks for comment, Bob. The title was explaining the problem affected me, not the cause. Anyway, I updated the title making it definitely more clear.
Thanks, worked like a charm!
Happy that it helped you.
Thank you so much, ive been lookin for this!
Perfect. Thanks for feedback.
Thank you for the blog post!
After reading this, I’ve packaged the `light` tool for Fedora, so guys, you might install it with DNF.
See https://copr.fedorainfracloud.org/coprs/frostyx/light/ and there is also a pending package reivew, so you might be able to install it directly from Fedora repositories soon.
Read my blog post on this topic if you want http://frostyx.cz/posts/light-when-xbacklight-doesnt-work
Wow! This is fantastic, really nice work. Why don’t you write a post on how you made the fedora package of light? Thank you so much for all.
> Why don’t you write a post on how you made the fedora package of light?
Well, the packaging process is properly documented and there are tons of videos and posts how to do it, so I saw no point in describing the technical details of fedora packaging. If you are interested in it, I can point you to some resources that I consider most helpful and which are surely better, than I could write by myself.
Also if you want to point for instance to light.spec file so you can package it for ubuntu or some other distro by looking on it as an example and use same values, I can, …
> I can point you to some resources that I consider most helpful and which are surely better, than I could write by myself.
I asked because I found the way you explain things really helpful, anyway resources you used are appreciated. Also, I’m going to study your repository.
thank’s. works!! there are any solution to send notify when change brigthness, like volume? thank you
You could use notify-send. For example:
# Screen brightness controls
# bindsym XF86MonBrightnessUp exec “xbacklight -inc 10; notify-send ‘brightness up'”
# bindsym XF86MonBrightnessDown exec “xbacklight -dec 10; notify-send ‘brightness down'”
thanks, it works!