Hyprland - Launch GUI App as Root

I’m experimenting with Hyprland, in addition to my default Gnome desktop. I am pretty new to Arch and Endeavour (and linux generally).

I’m trying to figure out why something happens: if I open gedit (or another gui app) with root privileges (“sudo gedit”) while logged in with Gnome, the terminal asks for my password and the app opens. If I do the same when logged into Hyperland, I get this message:

Authorization required, but no authorization protocol specified

(gedit:17652): Gtk-WARNING **: 12:14:02.268: cannot open display: :0

I have polkit installed, and GUI applications are able to elevate to ask for root privileges. E.g., if I open a /etc/foo.bar with Kate, and try to save it, Kate will ask for root privileges and when I enter my PW, it can save the file.

This isn’t a big issue - I know that I could use a command line editor or Kate, etc. I’m trying to understand the why of it.

Thanks in advance.

1 Like

This is totally different than running an application as root. In this case, it is just using root to save the file, not escalating the entire application to run as root.

Running a GUI application as root is fundamentally unsafe unless it has been specifically designed to run that way.

It is likely because you have lost all the environment variables a wlroots-based environment needs to run.

It would probably work with sudo -E but I would still recommend against it.

This is totally different than running an application as root. In this case, it is just using root to save the file, not escalating the entire application to run as root.

This makes sense. Thank you for explaining the difference.

Running a GUI application as root is fundamentally unsafe unless it has been specifically designed to run that way.

So, this is not a configuration or installation on my part. Rather it is expected and intentional behavior?

1 Like

Try sudo -E <application name>

Hyprland comes from sway/wayland.

Have a look here: https://wiki.archlinux.org/title/Running_GUI_applications_as_root

Also as for a text editor, mousepad for example works with pkexec:

pkexec mousepad