How can I make a GUI app always start/open as root?

First, yes, I know you shouldn’t do this. I know and understand all of the risks.

But how can I make a GUI app always open as root? Either with optional password prompt or without – I’m okay either way.

For example, I want to start snapper-gui but I always want it to start as root.

The root account is locked/disabled, so I can’t use the run as a different user option.

It’s up to the app to implement polkit so it prompts the user for a user account password with the correct permissions.

For apps that don’t, is there a way?

If there is no easy way, can I write my own polkit? Where can I find polkits so I can check other apps and copy one of theirs?

You could probably setup a script to run snapper-gui as root after doing some polkit magic, I don’t know how that would work though. Then create a desktop file for that so it’s in your menu. Perhaps using pkexec.

Not a good example, perhaps; as it’s not necessary to run snapper-gui as root. (It just gets the snapper daemon to do the work anyway.) If the config defines ALLOW_USERS or ALLOW_GROUPS that applies to the user, snapper-gui works fine not as root.

Yeah. I am looking into how.

Snapper was just one example. I have other apps that do not support this feature.

You can write your own polkit rules to grant “yes” permission for root actions, yes. I don’t know how it works for apps that don’t provide polkit actions though.

This is different than running apps as root, too.

I’ve done this in the past with systemd services and Discover + packagekit.

The annoyance there is that it’s in Python-like syntax (at least new polkit, old polkit was much nicer as it was plain INI).

Thanks. I will look into how to do this.