Score:2

Where is the "scripts" directory in Nautilus 43?

id flag

Where do you put the scripts that appear in the context menu when you right click in a folder or on a file in Nautilus?

Right click menu in nautilus for custom scripts

(Screenshot from a previous version of Nautilus)

My scripts used to work just fine in older versions, but no matter where I place them now, my scripts don't seem to be picked up by Nautilus.

FedKad avatar
cn flag
Put them under `~/.local/share/nautilus/scripts`.
IQAndreas avatar
id flag
@FedKad That was it! (I also realized the scripts weren't showing up because they weren't marked as executable ) Make the comment a full answer and I will accept it.
Score:1
cn flag

I normally put my scripts under my user directory called ~/.local/share/nautilus/scripts. One such sample script is given below:

#!/bin/bash
## Variables: (Refer to: https://help.ubuntu.com/community/NautilusScriptsHowto)
# NAUTILUS_SCRIPT_CURRENT_URI='file://... current directory'
# NAUTILUS_SCRIPT_SELECTED_FILE_PATHS='... each file is terminated with \n'
# NAUTILUS_SCRIPT_SELECTED_URIS='file://... each file is terminated with \n'
# NAUTILUS_SCRIPT_WINDOW_GEOMETRY=1920x999+0+0

echo -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -z 's/.$//' | xsel -b -i
zenity --info --no-wrap --no-markup \
  --title="File name(s) copied to Clipboard:" \
  --text="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"

You can save the above script as ~/.local/share/nautilus/scripts/CopyFile_Path and make it executable¹. After that, you can select some files in Nautilus, right click and go to the ScriptsCopyFile_Path menu item.

You can also group your scripts under sub-directories of the scripts/ directory. They will be displayed as sub-menu items in the right-click menu.

For more details, please look at another of my answers here.


¹ Refer to the man pages of xsel and zenity commands. If you don't have these commands on your system, you will have to sudo apt install xsel zenity.

Score:1
in flag

Based on the documentation, scripts are loaded from three locations in this order:

  1. $XDG_DATA_HOME/nautilus-python/extensions (i.e. ~/.local/share/…)
  2. nautilus_prefix/share/nautilus-python/extensions (i.e. ~/Development/…)
  3. $XDG_DATA_DIRS/nautilus-python/extensions (i.e. /usr/share/…)

After copying a Python script, we're asked to restart Nautilus to ensure the locations are read and any new scripts are loaded.

IQAndreas avatar
id flag
That seems to be specific to the `nautilus-python` package. Is that included by default in Ubuntu 22.10, or is that something you have to install explicitly?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.