I have created following policy file at /usr/share/polkit-1/actions/com.xyz.xyz.policy
<?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>
<vendor>XYZ Technologies Inc.</vendor>
<vendor_url>http://www.xyz.com</vendor_url>
<action id="org.xyz.policykit.pkexec.run-xyz">
<description>Run XYZ</description>
<message>Authentication is required to run XYZ</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xyz</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
</action>
</policyconfig>
and desktop file at /usr/local/share/applications/xyz-gui-root.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Name[en_in]=XYZ administrator (root)
Exec=pkexec xyz
Comment[en_IN]=Launches XYZ administrator
Name=XYZ administrator (root)
Comment=Launches XYZ administrator
Icon[en_IN]=/xyz/xyzroot.png
Icon=/xyz/xyzroot.png
When I search XYZ and run through Activity->Search, it doesn't show any activity, not even ask for password. But double clicking on xyz-gui-root.desktop file it works as expected with password authentication.
If I change
Exec=pkexec xyz
as
Exec=gnome-terminal -x pkexec xyz
it works fine with Activity->Search with authentication, but it opens a unwanted terminal.
What I am missing in above files? How can I avoid unwanted terminal to open with gnome-terminal entry? Is there any way to execute GUI application with authentication using pkexec or any other method like consolehelper?
Thanks in advance!