Last active
March 25, 2024 15:39
-
-
Save stokito/1cb8ab50722673adccaac6997c7b5f7f to your computer and use it in GitHub Desktop.
quickly select a file and then edit it. If needed ask for a root password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILE=$(zenity --file-selection); | |
if [ -z "$FILE" ]; then | |
exit | |
fi | |
if [ ! -f "$FILE" ]; then | |
dir=$(dirname "$FILE") | |
if [ -w "$dir" ]; then | |
if [ -x /usr/bin/gedit ]; then | |
gedit "$FILE" | |
else | |
pluma "$FILE" | |
fi | |
else | |
if [ -x /usr/bin/gedit ]; then | |
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit "$FILE" | |
else | |
pkexec pluma "$FILE" | |
fi | |
fi | |
else | |
if [ -w "$FILE" ]; then | |
if [ -x /usr/bin/gedit ]; then | |
gedit "$FILE" | |
else | |
pluma "$FILE" | |
fi | |
else | |
if [ -x /usr/bin/gedit ]; then | |
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit "$FILE" | |
else | |
pkexec pluma "$FILE" | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment