1

I have a laptop with Manjaro XFCE and I damaged my F2 and F3 keys, which operate the brightness of the display (up and down respectively) while holding the Fn key.

The xfce-power-manager works fine, and I can use the slider on the bottom bar, but I would like to know if I can remap brightness to other keys. I haven't been able to find a solution for now.

I tried instaling light package, as I saw in another reply, and using:

light -U 20

decreases the brightness as expected, but it has to be done as root, so my idea to remap that command to another key combination, doesn't work, because it doesn't have privileges.

Any idea? Thanks!

PolGZ
  • 53
  • 8
  • https://wiki.archlinux.org/title/backlight#xbacklight maybe? You could add shortcuts for `xbacklight -inc 5` and `xbacklight -dec 5` – Artem S. Tashkinov Aug 31 '21 at 13:21
  • @ArtemS.Tashkinov I tried that, but I got the "No outputs have backlight property" that the wiki talks about. But I don't have a `/etc/X11/xorg.conf.d/20-video.conf`, and creating it with the suggested content doesn't change the output (same "no outputs have backlight property" error) – PolGZ Aug 31 '21 at 14:13
  • Please report here https://gitlab.freedesktop.org/drm/intel/-/issues – Artem S. Tashkinov Aug 31 '21 at 14:57
  • As [commented here](https://unix.stackexchange.com/a/507333), using `acpilight` package instead of `xorg-backlight` package in **Arch** made the commands `xbacklight -inc 10` (and the decrease option) work. But again as with `light` package, I need sudo. I havn't been able to edit `sudoers` in a way that my user can run (just) that script without sudo. But that is another problem. If nobody has another idea, I will explore how to run a script like that. – PolGZ Sep 01 '21 at 16:21
  • I rolled back your recent edit tagging the title with "SOLVED". If you have a solution then consider adding that solution as a separate answer and accept it later (don't add it into the question). Accepting an answer will mark the question as resolved. Please see https://unix.stackexchange.com/help/self-answer You should be able to simply copy the text from [your most recent revision of the question text](https://unix.stackexchange.com/revisions/667022/3) and make a separate answer from that. – Kusalananda Sep 01 '21 at 18:06
  • @Kusalananda Sorry, I didn't knew I should answer my own post. And I don't know if there is a way one can recover all the markup format of a given revision. I don't find how to and having to put all the URLs, sections, format and everything back again... -.-. Maybe next time give the warning and give one day or so to do it? It's a real pain to put again all the markup code. – PolGZ Sep 03 '21 at 11:27
  • @PolGZ You can see all revision of your text by clicking the text saying [edited ...](https://unix.stackexchange.com/posts/667022/revisions) underneath the text. There you will be able to switch between seeing the markup text or the rendered text. There will be no next time, so no need for advance warning :-) – Kusalananda Sep 03 '21 at 12:10
  • @Kusalananda I really don't see an edit option in the [revision of the question](https://unix.stackexchange.com/revisions/667022/3). And in the edit of any "current" question, I can only see what there really is "at that moment", not the previous ones. But anyway, thanks for all your notes and I don't believe it will be a next time – PolGZ Sep 04 '21 at 16:31

1 Answers1

1

Finally I got to a solution. Here is what I did (better ways would be welcome!)

  1. Instead of xorg-xbacklight package as showed in the Arch Wiki as default option (because I got the error "no outputs have backlight property" that the wiki talks about, and using the .conf parameters showed in the wiki didn't solve it for me) I installed: acpilight package. It runs the same way as xorg-xbacklight:

    • xbacklight -inc 10 to increase, and
    • xbacklight -dec 10 to decrease. As suggested by @ArtemS.Tashkinov here in the comments.
  2. To control xbacklight and chenge backlight level, you need sudo privileges, so I needed to edit sudoers to make my user able to run the xbacklight command without asking for the password (but, for security reasons, of course, only that, and not any command):

    1. sudo visudo (vim like editor) or su and then visudo (with your default editor, in case your are used to nano)
    2. Add the following (changing username for your user):
      username ALL=(ALL) NOPASSWD: /usr/bin/xbacklight
      
  3. To avoid the possible error (I had it) /usr/bin/xbacklight: [Errno 13] Permission denied: '/sys/class/backlight/intel_backlight/brightness'; I added my user to the video group, which is the default in 90-backlight.rules (as I saw here) (change username for your user name):

    sudo usermod –a –G video username
    
  4. Create two scripts called bright-up.sh and bright-down.sh (or whatever you want), with this content:

    #! /bin/bash
    
    xbacklight -inc 10
    
    • Change -inc for -dec in the bright-down.sh
    • Change 10 for the value you want, like 5 or 20, depending on how much you want the brightness to change.
  5. Place those scripts in a directory like /home/user/.bin/ or wherever you want and give them execute permissions:

    chmod +x /home/user/.bin/brigh-up.sh /home/user/.bin/bright-down.sh
    
  6. Now create keyboard shortcuts pointing to those scripts according to your desktop environment/window manager. In XFCE in keyboard > keyboard shortcuts.

PolGZ
  • 53
  • 8
  • Thank you it was very helpful on Gnome too. I can now change the brightness but I don't get the on screen notification with the slider moving. Do you know how to get this further step? – Pablohoney Feb 19 '22 at 10:52
  • 1
    @Pablohoney Sorry, I only have Gnome on a Debian desktop system, so I can't test it. Maybe try using gnome dconf and directly bind brightness-keys to your prefered combination as showed [here](https://www.reddit.com/r/archlinux/comments/sia8qj/comment/hv7pdo6/?utm_source=reddit&utm_medium=web2x&context=3)? Instead of using my scripts. If not, try reading [this old ubuntu post](https://askubuntu.com/questions/400268/how-to-enable-notifications-while-changing-brightness-and-or-volume) or [this arch post using another notification daemon](https://bbs.archlinux.org/viewtopic.php?id=125115) – PolGZ Feb 20 '22 at 12:06
  • Ok, the solution of the first link works. Thank you. – Pablohoney Feb 20 '22 at 13:54