I wanted to use “pkexec” but found the “exec” in “nemo actions” ignores it.
The way round this was to put it in a script and get the “exec” to call it.
This is the script
#!/bin/bash
pkexec $@
and the resulting nemo action
[Nemo Action]
Name=Edit with Root
Comment=Edit as root
Exec=<pkexec xed %F>
Icon-Name=text-editor-symbolic
Selection=s
Extensions=nodirs;
Dependencies=xed;pkexec;
Extensions=txt;sh;fstab;policy;conf;rc;gen;xml;js;json;
Now “xed” doesn’t have a “pkexec” permission in /usr/share/polkit-1/action
Here it is called com.linuxmint.pkexec.xed.action.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.0/policyconfig.dtd">
<policyconfig>
<vendor>xed</vendor>
<vendor_url>xed</vendor_url>
<icon_name>accessories-xed</icon_name>
<action id="org.freedesktop.policykit.pkexec.xed">
<description>Run 'xed'</description>
<message>Authentication is required to run xed</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xed</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
Alternative suggestion in case you’re willing to try another editor: Open the file with micro editor (Install micro-manjaro package, it has some pre-defined settings).
When you want to save it and you don’t have the required permissions, it’ll ask if it should use “sudo” to save the file…
There is an alternative approach to this. Set the environment variable VISUAL to “xed” (I guess. I use “code -nw”) and use the Exec is “sudo -e %F”
It creates a copy of the file in /tmp, opens editor with that copy, and copies it back when the editor quits. So the editor itself does not run as root and does not mess up its configs.