It seems to be safe to use sudo with a suffix such as sudo -H or sudo -i rather than just sudo to open GUI applications, but it is possible to use pkexec already, with an alias as I have made, and use when I remember, to do so. The alias needed is
Code:
alias pkx='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'
but I accept that doing this is probably beyond the inexperienced user of Ubuntu.
Even more complicated is the possibility to make new pkexec policy files specifically for applications that you might want to use with root permissions. Such files need the following content:-
Code:
<?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="com.ubuntu.pkexec.thunar">
<message gettext-domain="gparted">Authentication is required to run thunar</message>
<icon_name>thunar</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/thunar</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
and in Xubuntu are put added to /usr/share/polkit-1/actions/ with names in form of com.ubuntu.pkexec.thunar.policy
I have the above file for thunar and another for mousepad (I just replaced the word thunar with mousepad) and both seem to work with no problems or faults. Again, probably not something for new users, but at least it proves it can be done.
Bookmarks