Now when I want to run a shell script (.sh or .csh file), I need to right click the file manager and click "open terminal here", then type "./xxx.sh" to run the shell script file. It is very inconvenient for me. However is there any way to integrate "run as shell script when I right click any flat text file"?

Here are the File Manager I use most frequently: Thunar (in Xfce4), PCManFM (in LXDE) and Nautilus(in Gnome).

closed as too broad by dessert, Eric Carvalho, George Udosen, N0rbert, Byte Commander May 8 '18 at 22:17

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please edit and clarify which file manager you're using – at least SpaceFM has this feature by default. – dessert May 4 '18 at 6:59
  • @dessert, I have added them at the bottom of my post. – pah8J May 4 '18 at 7:32
  • I think you should ask that question for one single piece of software at a time. For Thunar you can find a related question (or possible duplicate) here, for PCManFM here and for Nautilus here and here. – dessert May 4 '18 at 8:16
  • @dessert, Sorry for that, I just considered that they have same configure framework. – pah8J May 4 '18 at 9:23

Right click to run script in Nautilus

Here is how I setup this script: Nautilus can set desktop wallpaper. How can it set login and lock screen wallpaper?.

After using Nautilus to navigate and view an appropriate .png or .jpg file to use as login screen and lock screen wallpaper, Nautilus can set this for you using a script.

To create the script use:

cd ~/.local/share/nautilus/scripts/
gedit set-login-wallpaper

Paste in these lines:


## Set login wallpaper

# strip new line char passed by Nautilus

# Multiple files can't be selected.

if [[ $LINE_COUNT > 1 ]] ; then
    zenity --error --text "Ony one file can be selected at a time! "
    exit 1

# Object type must be "file..." (ie no directories, etc.)
if [ -d "${FILENAME}" ] ; then
    zenity --error --text "$FILENAME is a directory!";
    exit 1
    if [ -f "${FILENAME}" ]; then
        : # Bash noop
        zenity --error --text "${FILENAME} is not a file!";
        exit 2

# Build working file in /tmp
echo "[com.canonical.unity-greeter]" > /tmp/set-login-wallpaper.tmp
echo "draw-user-backgrounds=false" >> /tmp/set-login-wallpaper.tmp
echo "background='$FILENAME'" >> /tmp/set-login-wallpaper.tmp

# Must run as sudo
if [ "$EUID" -ne 0 ] ; then

    # Get sudo password
    PASSWORD=$(zenity --password --title="Set Login Wallpaper" --timeout=20)

    # copy working file to real file using sudo
    echo $PASSWORD | sudo -S cp /tmp/set-login-wallpaper.tmp \

    # compile using sudo
    echo $PASSWORD | sudo -S glib-compile-schemas /usr/share/glib-2.0/schemas

    # Already sudo so simply copy and compile
    # copy working file to real file
    cp /tmp/set-login-wallpaper.tmp \

    # compile
    glib-compile-schemas /usr/share/glib-2.0/schemas

exit 0

Save the file and exit the gedit editor.

Now mark the script as executable using:

chmod +x set-login-wallpaper

Open Nautilus and navigate to your directory with wallpaper images. Find an appropriate image and right-click on it. This drop-down menu appears:

Nautilus Right Click Drop Down

Click on the third option Scripts. Another drop down menu appears with all your scripts:

Nautilus set-login-wallpaper Drop Down

Select set-login-wallpaper.

When the script runs you will have to enter your sudo password.

Reboot and enjoy your new login and lock screen wallpaper.

Not the answer you're looking for? Browse other questions tagged or ask your own question.