I want to write a Nautilus script in Python. Is that possible? If it is possible, how can I do that?

1 Answer 1


Nautilus Scripts

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: ~/.local/share/nautilus/scripts

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 #!/usr/bin/env python3.

Once you have done all this, the script will be accessible from the scripts sub-menu of the right click menu in Nautilus.

nautilus scripts menu

See also:https://help.ubuntu.com/community/NautilusScriptsHowto

Nautilus Extensions

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).

Visit the web page of this library and view the documentation for more information.

  • 2
    Note that while the question and answer are specific to Python (and it does work), the same strategy is equally effective for Bash, Perl, Ruby, and other scripting languages so long as the #! points to the right interpreter. Aug 30, 2013 at 16:52
  • @Freedom_Ben Actually, it's not just the scripting languages that can be used, but also compiled executable. Nautilus simply executes whatever file is in that folder, and provides files on which user wants to operate to the executable via environment. Feb 20, 2017 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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