Search code examples
haskellxmonad

Xmonad: brightness and file permissions


I'm trying to setup my Xmonad to change the back-light intensity on my laptop.

However, to do so, I have to be able to write to the file /sys/class/backlight/intel_backlight/brightness, which requires the application performing the update to be sudoed (all other suggestions I have tried to use to change the back-light intensity seems to "simulate" it by reducing the brightness of the pixels rather than the back-light).

I've written the necessary code to perform this update and tested it using a sudoed ghci instance, however, when I add this to my Xmonad config, I get a permission denied error.

My question is, what are the usual methodologies for giving window managers extra permissions where required? (I'd ideally not want to change the permissions of this file)


Solution

  • I have this in in my sudoers configuration:

    # /etc/sudoers.d/brightness-mod
    ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/class/backlight/intel_backlight/brightness
    

    This allows you to execute, from user mode, commands like

    echo 200 | sudo tee /sys/class/backlight/intel_backlight/brightness
    

    Always use visudo to edit sudoers configuration stuff.