Nautilus - Support for nautilus scripts?

expected outcome: nautilus script runs
output: no output / action of any kind

Nautilus supports extensions, and also simple scripts, under “$HOME/.local/share/nautilus/scripts/” on conventional imperative systems. My simple scripts under this directory are seen by nautilus, but don’t work.

I noticed there’s a patch for extensions (https://github.com/NixOS/nixpkgs/blob/98da3dd0de6660d4abed7bb74e748694bd803413/pkgs/desktops/gnome/core/nautilus/default.nix#L52) - would a similar patch be needed for scripts? Has someone managed to get nautilus scripts to work, and if so, what steps were needed?

Thanks

Just tried creating ~/.local/share/nautilus/scripts/foo.sh with the following contents and making it executable and it works:

#!/usr/bin/env bash
for f in "$@"; do
	echo "- $f" >> test.log
done

Make sure the interpreter exists and all dependencies are available. Notably, NixOS does not have anything in /usr/bin other than env, and /bin only contains sh.

And if it depends on more than just programs on PATH, you might need to package the script similarly as described in How is XDG_DATA_DIRS set for some apps? - #6 by jtojnar.

1 Like

I indeed hadn’t updated my shebang(s) to invoke bash via env; a few replacements later and they’re all working fine.

For anyone else in a similar situation of confusion to mine, jtojnar’s linked resource is great, as is the additional resource linked within it at the bottom.

Thank you again!