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.

From time to time I come to ideas of actions I'd like to have available in a menu which pops up when I right-click on files in Nautilus. How to add them there? Is there something like Thunar UCA plugin for Nautilus?

share|improve this question

4 Answers 4

up vote 11 down vote accepted

Context menus of Nautilus can be customized by Nautilus extensions.

You can also place plain shell scripts under the ~/.gnome2/nautilus-scripts directory, and they will appear in file context menu under Scripts submenu.

share|improve this answer
1  
Please note that as said in askubuntu.com/questions/281062/… if you are on ubuntu 13.04 which uses a newer version of Nautilus, you are supposed to use ~/.local/share/nautilus/scripts folder to put your scripts in. And even then it will only show up scripts when you right click on a file or folder and not empty space. –  Logan Jul 3 '13 at 14:59

One can Use python-nautilus extension as an alternative to nautilus-actions.

To install:

sudo apt-get install python-nautilus

A simple example:

import os

from gi.repository import Nautilus, GObject

class ColumnExtension(GObject.GObject, Nautilus.MenuProvider):
    def __init__(self):
        pass
    def menu_activate_cb(self, menu, file):
         os.system("write here your simple bash command & pid=$!")

    def get_background_items(self, window, file):
        item = Nautilus.MenuItem(name='ExampleMenuProvider::Foo2', 
                                         label='Name of your item', 
                                         tip='',
                                         icon='')
        item.connect('activate', self.menu_activate_cb, file)
        return item,

Copy this python script under ~/.local/share/nautilus-python/extensions and restart nautilus. When you right click on the desktop and select your item, your simple bash command will be executed :)

share|improve this answer
    
you may need to create nautilus-python and extensions folders if they are not there. –  souravc Jun 11 at 14:38

Nautilus Actions

We may define our own right-click context menu items with nautilus-actions Install nautilus-actions.

  • Run the Nautilus-Actions Configuration Tool either from the Dash, or from a terminal with

    nautilus-actions-config-tool
    

enter image description here

  • In the Action tab give your action a sensible label, e.g. "Open in Terminator" and choose to display this in the selection or the context menu.

  • Next open the Command tab to enter the commands to run

enter image description here

  • Give in the full path to your command (/usr/bin/command_to_run) and program options.

  • After logging out and in again the right click context menu below will be displayed:

enter image description here

share|improve this answer
    
Is this still up to date? –  RolandiXor Feb 17 '12 at 14:38
2  
Nautilus Actions perform as expected in 12.04 –  Takkat Feb 21 '12 at 20:44

If you want to be able to do something at any time, do like ulidtko says and use ~/.gnome2/nautilus-scripts.

If you want to be able to customize when you see it, install the nautilus-actions package, then go to System->Preferences->Nautilus Actions Configuration.

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.