Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 14 down vote accepted

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. You will probably want to rename it so that it has a descriptive file name, without the '.py' extension. You will also need to add #!/usr/bin/env python as the first line of the file. 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

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 install python-nautilus).

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

share|improve this answer
    
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. –  Freedom_Ben Aug 30 '13 at 16:52

I assume you want nautilus context menus extensions, there is a detailed article describing how to do it:

http://saravananthirumuruganathan.wordpress.com/2010/08/29/extending-nautilus-context-menus-using-nautilus-actions-scripts-and-python-extensions/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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