Nautilus-Actions: Adding New Functions to Nautilus Right-Click Menu has Never been this Easy!

Gnome desktop didn't used to like this simple you know. Apparently it used to come with a huge list of features and configuration options which were cleaned up about 80-90% when the made the switch to the Gnome 2+ back in the day (around 2000-2001 I think).

These days it's pretty much simple and it has been heavily criticized by many + by myself too (apparently someone called Linus Torvalds was one of them :)). Although I wrote that post few months ago but apparently, the disappointment came from the experiences that I had in the past few years (since I decided to stick-with GNU/Linux).

But the point is that, at lest in the recent years it seems that the developers has come up with their own versions of little "solutions" in order to fix some of those "missing" features in Gnome desktop (ahh, the power of Open-Source software :D).

Anyhow, if you're just like me having a continuous "hate and love" relationship with the Nautilus file manager and trying to find a way out of that too simple right-click menu and thinking if there's a way that you can add functions of your own to that with ease?... well my friend, you sure can do that!.

There is apparently an application called "Nautilus-Actions" which is I think A Nautilus script (they are like "addo-ons" which expands the features of Nautilus via their API).

And I gotta say folks, after playing it with like 5-10 minutes, seriously if you know your way around GNU/Linux commands (trust me, I know very very little about 'em commands, still learning just like you) then this is one heck of an application that can totally change how Nautilus behave!.

Main features...

Hi!, my name is "awesome" ;-)...

*. Add/remove new menus to the Nautilus file manager right click menu.

*. Add/remove the appropriate commands.

*. Use Mimetypes:

For instance, say that you wanted the command "Mplayer" to be displayed once you right click on a multimedia file extension ".mkv", then you can use this feature to associate the command for that file-type only.

*. Include/Exclude folders:

Say that you wanted the menu to only display once you right-click in a certain location in Nautilus, then this is the feature that you can use for that.

*. Display the menu on selected objects or on empty spaces (or them both).

*. Import/Export pre-configured scripts.

These are very little of its features. But I'll give you an example which would help to understand it much easier (I was addressing the newbies only, for the underdogs: respect!, respect! :) ).

Lets install it...

You can install the "Nautilus-Actions" app in Ubuntu 11.04 Natty Narwhal, 10.10 and 10.04 by using the below command.
sudo apt-get install nautilus-actions
Now once installed you should be able to launch it via the main desktop menu or by using the below command after pressing "Alt" + "F2" keys on your keyboard.
You can obtain a huge list of pre-configured scripts from this page if you like too. 

But how to add a program "shortcut" of your own?

Well, although I totally don't want to, but let's say that I wanted to launch the "Totem" media player using nautilus right-click menu. Okay then, after launching the app you should see a window similar to the first screenshot.

1. Under the "Action" tab: in the sub heading "Nautilus item" you'll see two check-mark boxes. The first one is enabled by default which makes sure that the new menu item will only appear when you select something in Natilus and right-click on it.

But if you want the menu-item to be displayed only when you right-click on an empty space, then remove the check-mark on the first one and add a check-mark on the second one that says "Display item in location context Menu".

If you put a check mark on that which says: "Display item in the toolbar", then it'll also appear in your Nautilus tool-bar too!...

2. Now, you'll see another  sub heading called "Context-label". Now as shown below, just replace the text in that box with "Open Totem" (you can add any name here since this is just the display name that'll be shown in the new menu).

3. Under "Tooltip" (above screenshot): type whatever the text you want (which is optional) and obviously it'll show a nice tooltip description about that menu-item.

4. Under "Icon": you can choose an icon to be displayed with the menu. But for performance issues, I humbly advice you to try not to use icons.

Associating the menu with the actual command...

5. Now, click on the next tab called "Command". Under the sub-heading "path" just enter the below command (since we're trying to Totem player) and leave other options alone.

As mentioned above, you can use other tabs to set things such as making the menu-item visible in a certain location, etc ... but if you're totally new to this, then both the "Action" and "Command" tabs are the ones that we need.

6. Now just click on its menu and go to: "File" -> "Save" and close the application (this is important, otherwise in my case, Nautilus failed to update the settings).

7. To make these changes apply to Nautilus we have to restart it.

For that use the below command (beware: before running make sure you have closed or completed any processes related to Nautilus such as file-copy, etc otherwise they'll be terminated!).
nautilus -q

That's it! and below is a screenshot of my Nautilus after adding both Totem and Gedit (Gnome's text editor) to the right-click menu.

Not just Totem, as long as you know the appropriate command name of the application that you want to add, you can add any application to the Nautilus file manager's right-click menu + you can even add other advanced features such as "refresh" command for instance as well.

But how the heck can I find actual command for a given program?

Well, for knowing the actual command-name of the installed applications, as long as they show-up in your main desktop Menu, there's a simple trick that we can use.

In the recent years, Gnome came with a separate application called "alacarte" which lets us easily add/remove applications in the main application menu. Not only that, by using this app we can easily figure-out the name and the actual command associated with it which helps to launch the program itself too.

So, just put the below command in after pressing "Alt" + "F2".

Now, from its main window, navigate to any sub-menu and locate your program, and then simply double click on the icon (I just double clicked the "Ubuntu Software Center" icon) which should reveal the "properties" of the application.

See that selected text, yup, that's the secret formula :P...

Now under the sub heading "Command", the text in that field is the location + the command of that application that you just double clicked. For instance, if we want to manually launch the Ubuntu software center, then we should use the command...
/usr/bin/software-center %u 

software-center %u

Since "/user/bin" actually the location which will be recognized automatically by Ubuntu (or in GNU/Linux in general), most of the time, you can ignore the "/usr/bin" part.


So if you want to easily customize the Nautilus file management utility's menu (for fun and adding some efficiency, hopefully :D), then first figure-out its "actual command" and then open the awesome Nautilus-Actions utility and after filling the other fields, under the command section, simply copy and paste, make your changes and you're good to go.

Well, that's about it. If you have questions just ask. Enjoy it :).

No comments:

Post a Comment