Replacing gksudo with pkexec: editor doesn't start in current folder
Solution 1:
As mentioned in comments, gksu
was "orphaned" in 16.04 but you can still install it with:
sudo apt install gksu
That said I made a wrapper script for pkexec
a long time ago that might be of some interest:
#!/bin/bash
# Usage: gsu gedit file1
# -OR- gsu natuilus /dirname
COMMAND="$1" # extract gedit or nautilus
ABSOLUTE_NAME=$(realpath "$2")
pkexec "$COMMAND" "$ABSOLUTE_NAME"
#log-file "$ABSOLUTE_NAME" ~/bin/log-gsu-"$COMMAND"
I named the wrapper gsu
as a short form of gksu
. The log-file
script is a separate project which I commented out in the script for this answer.
You need to setup gedit
and nautilus
policy kits before you can use this script as the comments reference. In your case you would need to setup a policy kit for leafpad
.
Hope this helps!
Solution 2:
I use this alternative in desktop launchers or bash scripts to keep the gksu feel:
bash -c 'sudo -i nautilus;'
... though no pkexec here - pls don't tell my admin.