The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 2,296β€…    Votes:  5β€…    βœ… Solution
Tags: gksudo   pkexec  
Link: πŸ” See Original Answer on Ask Ubuntu πŸ”—

URL: https://askubuntu.com/q/1026821
Title: Replacing gksudo with pkexec: editor doesn't start in current folder
ID: /2018/04/21/Replacing-gksudo-with-pkexec_-editor-doesn_t-start-in-current-folder
Created: April 21, 2018
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


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!

⇧ Improve initial use of `find` performance time What is the best way to install Ubuntu on cloud  β‡©