How To Add Custom Functionality To Nautilus [Linux]

Ads by Google

nautilus   How To Add Custom Functionality To Nautilus [Linux] Nautilus, as you know, is the default file manager for Gnome Desktop Environment. It’s where you wander and spend most of your time, when you are not browsing the web or firing commands at the command prompt.

So obviously it would be cool and productive to some tools that make your work easier. Nautilus actions allow you to add custom functionality to Nautilus. This is achieved via the right click menu. You can inter-convert files in various formats, mount ISO files, merge PDF files all from within Mautilus without launching any other application all from the right click context menu. The possibilities here are only limited by your imagination!

Adding such custom functionality is pretty easy. You don’t need to be a Linux hacker or programmer to get it working. All you need is:

  • The ‘nautilus-actions’ package
  • The knowledge of an equivalent command to achieve the same objective

The Nautilus-Actions Package

The nautilus-actions package is what provides you with a nice graphical tool where you can create, edit and remove nautilus-actions or the custom functionality we are looking for. It is easily available through your distribution’s package manager.

Knowledge Of The Command

As a Linux user you are no stranger to the fact that most of the tasks that you perform via the mouse and GUI can be accomplished via commands as well. Want to print resume.doc? Just enter ‘oowriter -p resume.doc’ in the terminal. Need to convert a jpeg file to gif? Enter ‘convert logo.jpeg logo.gif’ (requires imagemagick). Want to set an image as wallpaper? Type ‘gconftool-2 -t str –set /desktop/gnome/background/picture_filename ‘.

Ads by Google

So you can achieve almost anything from the command line and this is what we will exploit here.

Create An Action

Let me illustrate the steps you need to follow with an example. We will create a nautilus action to convert flv files to mp4 suitable for playback in an iPod Touch/iPhone. I will use ffmpeg for conversion, so make sure you have it installed (mostly available through package managers, ‘sudo apt-get install ffmpeg’ on ubuntu) if you plan to use the action or try along.

  • Go to System > Preferences > Nautilus Actions
  • initialnact   How To Add Custom Functionality To Nautilus [Linux]

  • Click on Add. (Note that you can edit, remove, import/export actions from here on in)
  • optionsnact   How To Add Custom Functionality To Nautilus [Linux]

  • In the label field, type the text you want to appear in the right click context menu of flv files. You can choose an icon and specify a tooltip which provides information about what this option would do. I will skip both of these as they are not essential for functionality.
  • Path and Parameters is where all the action is. In path put in the utility that you will use to perform the action. We will be using ffmpeg so put in /usr/bin/ffmpeg here. If you are not sure where the utility resides use the ‘where is’ command to find out. eg use ‘whereis ffmpeg‘ to know its location.
  • The parameter line is going to be scary so hold your breath and copy paste:’ -i %d/%f -f mp4 -vcodec libxvid -maxrate 01000 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -s 480×320 -ab 0128000 -b 400000 %d/%f.mp4 ‘  Don’t blame me, this is what you need to enter on the command line to convert flv to mp4 with ffmpeg (refer man ffmpeg for more details)! What is noteworthy is the %d and %f. These two provide information on which file you right clicked. Click on the legend button for more details. By the way, I am no video expert and I don’t claim the options above to be perfect, it does the job just fine. So if you have some suggestions please feel free to share them in comments.

    conditionsnact   How To Add Custom Functionality To Nautilus [Linux]

  • Next click on the condition tab.  This is where you will limit your options to the context menu’s required file types (flv in our case). You can limit your choices via the filename metacharacters or via the mimetype. Additionally you can specify if your action appears for files only or for files and folders as well. We will type ‘*.flv’ for filename and apply our actions to files only.
  • advancedcondnact   How To Add Custom Functionality To Nautilus [Linux]

  • In the advanced condition tab, you can further limit your choice to local files, samba shares, ftp files etc. We will choose local files here.
  • Click OK and you are done!

menunact   How To Add Custom Functionality To Nautilus [Linux]

Now go look for an flv file. Right click and presto, there is your very own custom ‘Convert for iPod’ option. Click on it and you will see a new mp4 file in the same folder.

bothnact   How To Add Custom Functionality To Nautilus [Linux]

For The Lazier Geeks

If the above seems like too much work for you, check out here for ready made actions!

Some Tips

Experiment on the command line with file names and the options for the utility. When you are pretty sure about a functionality that you require for certain type of files, replace the file name in the command with %d/%f.

If you want to act on more than one files use %M instead.

For performing complicated operations (e.g. to email a file to someone from the context menu) its best to create a script and pass the appropriate arguments within the script. This will help you to debug and allow greater control altogether.

With nautilus actions you can transform any task that you perform often or a cumbersome command line like above into a convenient easy to use context menu option. Here is the ‘Convert for iPod’ Action if you need it. Check out other nautilus addons previously covered on MakeUseOf.

Have you used nautilus-actions before? What actions you are currently using? Have a great idea to turn into an action? Share with us in the comments, who knows you might just get an action! Oh and in case you are puzzled by the topmost image, it is a nautilus!

Ads by Google

10 Comments - Write a Comment

Reply

Raseel

I really liked this article. I think Nautilus action scripts can be really useful to me. I followed some links in the article and discovered even more Nautilus-related functionalities.
I used to always think MakeUseOf.com was a non-Linux website. It’s so cool to know you guys have Linux enthusiasts on-board as well.

Varun Kashyap

That’s MakeUseOf for you! Thanks for the kind words Raseel

Reply

Vadim P.

Now that is useful. Thanks!

Reply

Dave

Now that’s awesome! I’ve always just made scripts for nautilus, but this makes it easier. Thanks for the tips.

Reply

Andre

I always see the mime in the context menu, no matter which mimetype .

Bug?

Reply

Zac

Just what I need, thanks.

NB: I got to here from Digg “15 Great Tips For Ubuntu”

Your comment