Ask Your Question

Revision history [back]

The thing is that if you want to run as root a graphical application you have 2 ways:

1.- Open the terminal and type:

$ sudo app_name


2.- Add a policy kit rule:

In /usr/share/polkit-1/actions you have to create a xml file with the information about the application you want to run with privileges. In my case I wanted to run glogg cos I need to open system log files and had to be root for that.

After you create the xml file you have to edit the .desktop file in /usr/share/applications, adding before the binary name, the pkexec command.

That's all. Then you've got your application asking for root password.

For glogg I create this XML, named org.freedesktop.policykit.pkexec.glogg.policy (path: /usr/share/applications/)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"

    <vendor>Nicolas Bonnefon</vendor>

    <action id="org.freedesktop.policykit.pkexec.glogg">
    <description>Run glogg with elevated privileges</description>
    <message>Authentication is required to run glogg as root</message>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/glogg</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>


And the glogg.desktop file (path: /usr/share/applications):

[Desktop Entry]
GenericName=Log file browser
# %f because glogg supports only one file for now
Exec=pkexec glogg %f
Comment=A smart interactive log explorer.

[Desktop Action Session]
Exec=pkexec glogg --load-session %f
Name=Open With Previous Session

[Desktop Action NewInstance]
Exec=pkexec glogg --multi %f
Name=Open In A New glogg Window