How to launch vorta as root from launcher

Hello,
I need to run Vorta as root.
For that, I created a file in the folder:
/home/pierluigi/.local/share/applications
called
vorta.desktop
which contains:

[Desktop Entry]
Type=Application
Icon=/home/pierluigi/AppImages/.icons/backup.svg
Name=Vorta Root
Comment=Vorta Root
Exec=sudo vorta
NoDisplay=false
Hidden=false

It didn’t work at all.
I tried too:
Exec=psexec vorta
Nothing.

I’ve searched a lot on the web, but I’ve not found a solution.

I made a dirty fix, adding at the end of the file:
Terminal=true
so it works, but I have the terminal opened.

I’m using Wayland.

Can Someone help, please?

Wayland or X? It matters, see Running GUI applications as root - ArchWiki

Sorry, my bad!
Wayland.
I added it in the first post.

Nothing.
I can’t understand where the problem is.

Reading https://wiki.archlinux.org/title/Running_GUI_applications_as_root,
so I created a file called vorta-launcher:
nano vorta-launcher
chmod +x vorta-launcher

and then in vorta.desktop I called vorta-launcher.

In vorta-launcher, I put:

xhost si:localuser:root
sudo -E vorta
xhost -si:localuser:root

I replaced sudo -E vorta with pkexec vorta, too, but nothing changed.

Edit:
With the current launcher, I can’t see anymore the vorta icon in notifications.

As i know it needs to be a .desktop file.
In your case vorta-launcher.desktop

I created a .desktop file that, in a line, it contains the:
Exec=vorta-launcher call to a file that contains the 3 rows of commands.

I don’t know how to put several instructions like:

xhost si:localuser:root
sudo -E vorta
xhost -si:localuser:root

in that .desktop file.
It’s my ignorance, of course.

Wait.
pkexec (PolicyKit) is the way to go.
But you need a policy file.

I.e.
(Supposing you have installed Vorta as an RPM from the Fedora repository).
Create a file named
/usr/share/polkit-1/actions/org.freedesktop.policykit.vorta.policy
containing this policy (example):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
    <action id="org.freedesktop.policykit.pkexec.vorta">
    <description>Run Vorta as root</description>
    <message>Authentication is required to run Vorta</message>
    <icon_name>package-x-generic</icon_name>
    <defaults>
        <allow_any>auth_admin</allow_any>
        <allow_inactive>auth_admin</allow_inactive>
        <allow_active>auth_admin</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/vorta</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
    </action>
</policyconfig>

Now, you can test from the command line.
pkexec vorta
A GUI spoke should ask for your password.

Now let’s create the .desktop file in your home. Let’s call it “VortaRoot” in order to have a second icon.
.local/share/applications/VortaRoot.desktop (Adapted from /usr/share/applications/com.borgbase.Vorta.desktop)

[Desktop Entry]
Name=VortaRoot
GenericName=Backup Software as root
Exec=pkexec /usr/bin/vorta
Type=Application
Icon=com.borgbase.Vorta
Categories=Utility;Archiving;Qt;
Keywords=borg;
StartupWMClass=vortaroot

Run update-desktop-database ~/.local/share/applications
Now you have two icons. The normal one and the privileged one.

5 Likes

I want to thank you so much!!
Your post is great!

1 Like