Run programs as sudo through dmenu, is it possible?

It is kinda annoying to open a terminal an launch a program through there whenever the program needs sudo access. So I was thinking if it is possible to launch a program as sudo through dmenu and if it is possible how would I do it?

I have tried opening dmenu and type "sudo name_of_program". But that doesn't work.

The programs that require elevated privileges for certain tasks, do that trough polkit not by running the GUI of them as root.
Never run programs as root !!!

As an example then. If I wanna change settings in nvidia-settings I need to launch it as root in order to be able to save the settings later. Or if I wanna change some settings for my mouse I use piper but in order for the changes to take effect I need to launch piper as root.

The .nvidia-settings-rc should be saved in your user directory, no need for elevated privileges. If you are referring to /etc/X11/mhwd.d/nvidia.conf then we talk about configuration, not settings, and i can understand it requires elevated privileges to write that file, but how often is that needed and why not using and editor polkit to append those modifications?

Please point me on their documentation where it states that requires root to be opened and save settings. :slight_smile:

I use gksu, it's still useable?

just prepend gksu with the command in the dmenu prompt.

dmenu is also pipeable with any input, you could pipe it with sed or smthin' to have pimped sudoed dmenu on different keybind

Instead of prepending sudo, use pkexec. Other options include gksu and zensu depending on what you have installed.


This script helps if powermizer settings don't stay at boot.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.