Howto: Add Items to the Right-Click Menu in Nautilus
Introduction
Linux is known for letting users configure settings to customize nearly
every aspect of their desktops. In the past, this has largely been
relegated to the more advanced crowd, since it often required editing
text-based configuration files; but as Linux becomes more mature, many
GUI programs are being written to allow easy customization of the user
interface. The Nautilus Actions Configuration utility is one such
program that lets you add custom commands to the right-click menu in
Nautilus, the default file manager in Gnome.
Installation
Ubuntu users can install the Nautilus Actions Configuration utility via the software repositories using the command:
sudo apt-get install nautilus-actions
Users of other distributions should check their package manager for the program, or you can visit the
Nautilus-Actions project page for more downloads, including source files.
Adding a new Item
Once installed, you'll find a new entry in your System menu, under
"Preferences" titled "Nautilus Actions Configuration." Opening it will
give you this window:
To add a new menu option, click the "Add" button. For this
example, I will be adding an option to enqueue audio files into my
favorite MP3 player, Audacious; but you can add an option for anything
you like using the same basic steps.
Menu Item & Action
This window is where you will specify the command to be run, and what you want the listing in the menu to be called.
There are five fields here:
| Field |
Use |
| Label |
This is the text that will appear in the right-click menu. Here I've chosen, "Add to Playlist" |
| Tooltip |
This text will appear in the status bar
in your Nautilus window. You should enter some brief text that explains
what clicking the function will do; in my case, I have set it as
"Enqueue in Audacious Playlist." |
| Icon |
The icon you want to appear next to the
"Label" in the right-click menu. Clicking on the Browse button will
take you to the pixmaps folder, which is where most system icons are
kept. I have selected the Audacious application icon. |
| Path |
Here, specify the location of the program
you want to call when the menu item is clicked. Since I am using
Audacious, I ran the command which audacious in a terminal, which tells me that the audacious program is located at /usr/bin/audacious. |
| Parameters |
Here, specify the command-line options
to use when calling the application. To find out the available commands
for your application, open a terminal and run [command] --help or, for a more detailed listing, use man [command]. In my case, I found that the "-e" flag is used to enqueue a file in the playlist, so I am using "-e" as my parameter.
Next, click on the "Legend" button. You'll see a window that shows you
all the available options you can append to the parameter field:
In this case, since I want to be able to enqueue multiple files, my complete Parameters field is: -e %d%M which means "enqueue the multiple files I've selected into the playlist. |
Right below the "Parameters" field, you'll see an example
output of what will be run when you click on the command in the
right-click menu. You can test it out in a terminal, to make sure that
it will do exactly what you want it to do; if it isn't successful, go
back and repeat the steps for the "Parameter" field until you get
things right.
ConditionsThe Conditions tab allows you to set
which types of files will include the new menu item when you
right-click on them. Since, in my case, I want to be able to enqueue
audio files, I've set the "Filenames" field to contain common audio
files (mp3, flac, m4a, etc) seperated with a semicolon. I've also
decided to use the "Mimetypes" field to include any audio file.
To find out the mimetype of a certain type of file, right click
on an example file (in my case, I used an mp3) and click on the
"Properties" option. You will see a field marked "MIME type" that shows
you how the system reads that particular kind of file. Audio files, for
example, will be listed as "audio/[codec]" and since I want my new menu
entry to work for all audio files, I use "audio/*" as my Mimetype
option. "*" is a wildcard; it means "match anything that goes here," so
it will include all codecs.
Advanced ConditionsThe "Advanced Conditions" tab
is something most users may not need to adjust; it deals with how the
file is being accessed through Nautilus. Since Nautilus has the ability
to read files over Samba, FTP, Secure FTP (SSH), and Webdav, you can
limit which different with which protocols you want your menu item to
apply.
In my particular case, I've enabled SMB, FTP, and SFTP, since
I am using these different protocols to access various machines on my
network. If you don't know what these are, or you're not using them,
it's safe to either leave just the "Local Files" option checked, or to
check them all.
The result
Once I saved my new menu
item, I immediately wanted to try it out! So I navigated to a folder of
some music I've ripped from my personal CD collection, and
right-clicked on some mp3 files. Sure enough, my context menu had a new
option:
Clicking on this option did just what I expected; Audacious
kept playing the file that was already being played, and all the new
files I'd selected were added to the playlist. Neat, huh?
Import/Export
Another nice feature of
the Nautilus-Actions utliity is that you can export and import
configurations; this is great if you want to back-up your changes, or
if you have multiple machines that you want to customize. You can
select which menu items you want to export and save them to a file, and
then transfer them to another computer, and use the import function to
instantly add them to the right-click contextual menu. While this might
not be particularly useful if you're only using a single workstation,
businesses and large networks will find that this saves quite a bit of
time for customization.
Conclusion
The
Nautilus-Actions-Configuration utility is a simple, easy-to-use program
that makes it a snap for even the most inexperienced user to add custom
items to a Gnome menu. Unfortunately, it only works in Nautilus, but
I'm sure there are other programs available for Thunar (XFCE4's primary
file manager) and for KDE. If you've ever wanted to add extra menus
options, but you just didn't know how, this is one program that will
become a must-have on your desktop.
--
Nirmal D Pathak.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I was born free!
No Gates and Windows can restrict my Freedom!!
Enjoy Linux!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~