I want to write a Nautilus script in Python. Is that possible? If it is possible, how can I do that?
Nautilus scripts can be written in any programming language, including python. You just need to make your python source file executable and copy it to
~/.gnome2/nautilus-scripts in Ubuntu versions prior to 14.04. For Ubuntu 14.04 and newer the directory is different:
You will also need to add
#!/usr/bin/env python as the first line of the file. Note that by default
#!/usr/bin/env python points to Python2. If you need Python 3 specifically, use
Once you have done all this, the script will be accessible from the
scripts sub-menu of the right click menu in Nautilus.
Nautilus extensions have more flexibility than scripts - eg. they can be used to add an item directly to the context menu. There is are python bindings available (python-nautilus).