Extending Nautilus with Scripts

Nautilus is the default file browser we get with Gnome. Today I found out about wonderful feature of it. We can very easily extend Nautilus functionalities by adding our own custom scripts.  These scripts can be any executable file like shell script, python script or even C/C++ program.  You only have copy your scripts to
~/.gnome2/nautilus-scripts
We can get information such as current directory path, selected files using environmental variables set by Nautilus. Full set of variables are as follows.
  • NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -lists the paths of the currently selected files, separated by newlines. Works only on local filesystem.
  • NAUTILUS_SCRIPT_SELECTED_URIS - contains the URIs (file://file) of the selected files, separated by newlines. Works on both local and remote filesystems.
  • NAUTILUS_SCRIPT_CURRENT_URI - contains the URI of the current directory. Works for both local and remote filesystems.
  • NAUTILUS_SCRIPT_WINDOW_GEOMETRY -provides the window location and geometry of the browser window.
Nautilus also passes list of selected files as args to your script.  So we can use them to do what ever processing we want to do.

This is a simple script that will prompt all selected files in a message box.

#!/bin/bash
#Author: M.A.C.Sandarenu http://sandarenu.blogspot.com
for arg
do
fileList="${fileList}${arg}, "
done
zenity --info  --text="You have selected following file(s) ""$fileList"
 

Reader Comments



Tribune to Heros

Tribune to Heros
We will never forget the sacrifices you made to protect our country....

Subscribe


Get Google Toolbar Button

Enter your email address:

Delivered by FeedBurner