Can xmonad spawn processes with sudo permissions?

0

I'm trying to configure xmonad to change my brightness when I press the brightness increase/decrease buttons on my laptop's keyboard. This is my xmonad.hs, with some irrelevant parts snipped:

main = do
  xmproc <- spawnPipe "/usr/bin/xmobar /home/zac/.xmobarrc"
  xmonad $ def
    { ...
    } `additionalKeys`
    [ ....
    , ((0, 0x1008FF03), spawn "sudo nudge /sys/class/backlight/intel_backlight/brightness -5")
    , ((0, 0x1008FF02), spawn "sudo nudge /sys/class/backlight/intel_backlight/brightness +5")
    ]

I've written a program called nudge that "nudges" the value of a file by a given amount. The exact command works, when I run it manually from the terminal, and I've confirmed that the keys are the correct ones by spawning a different process when they are pressed. So, I've come to the conclusion that the problem is that xmonad isn't allowed to run sudo.

Presumably, though, it is possible to run sudo from xmonad, otherwise a lot of things wouldn't be doable. So, how do I do this?

(P.S. Perhaps there is an easier way to change the brightness on Linux - if that is the case, I'd like to know, out of interest, but I'd rather do it this way (writing a program) anyway.)

Zac

Posted 2019-10-08T12:05:16.497

Reputation: 143

There is probably some errors in your xmond log. – Chris Stryczynski – 2020-01-05T13:47:12.073

No answers