Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.67k stars 709 forks source link

how to run an "on-click" command as root #791

Closed udaemon closed 4 years ago

udaemon commented 4 years ago

Hi, I was not able to figure out how to run a command as root when a module is clicked. to be precise, I want to start cpupower-gui when I click the icon of the cpu module, but neither "on-click": "sudo cpupower-gui" nor "on-click": "swaymsg exec sudo cpupower-gui" work. I shall mention that I even need to add the option -E or -EH to sudo: "on-click": "swaymsg exec sudo -EH cpupower-gui".

cpupower-gui needs to be granted root privileges in order to apply any changes.

any hint is very welcome. thank you!

maximbaz commented 4 years ago

Is your sudo passwordless, or did you remember to make an exception for these commands in /etc/sudoers? I would guess if you look at htop you would see sudo cpupower-gui pending there waiting for you to enter password...

udaemon commented 4 years ago

thanks, maximbaz, that could be the right hint: while i have put a sudoers exception for cpupower I haven't for cpupower-gui... will try when I'm back home from travelling.

udaemon commented 4 years ago

to provide a final report on my question: it took me a while to understand that this is rather a polkit-issue, i. e. to grant certain permissions on another level than within the terminal-root-realm. and with the help of this comment I was able to solve my issue resp. answer my question.

actualdankcoder commented 2 years ago

i had the same situation, i followed the same comment but did "on-click": "pkexec cpupower-gui" instead of "on-click": "sudo cpupower-gui". in case anyone reads this thread in the future