This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature

Extending Nautilus with Scripts and Extensions

By Peter Enseleit on May 16, 2006 (8:00:00 AM)

Share    Print    Comments   

Nautilus, the GNOME file manager, has a host of functionality for browsing and managing file systems, and for accessing remote servers including Windows shares, FTP servers, SSH servers, and WebDAV servers. On top of its built-in capabilities, you can extend the functionality of Nautilus by using Nautilus Scripts and Extensions. It's not too hard to do, and I'll show you how to get started.
#!/bin/bash

if [ -x sylpheed-claws-gtk2 ] then
      sylpheed-claws-gtk2 --compose --attach $*
fi

Nautilus Scripts are run in the shell. All scripts start with a line that tells the shell which program to use to run the script. In this case, the script should be run using the bash shell.

The next line is a test to see if the program you want to run is installed and executable. If the program is not detected, or is detected but is not executable, then the call to Sylpheed-Claws will not be made.

Then comes the command to open Sylpheed-Claws with parameters that instruct it to compose a new email message and add all the files selected in Nautilus as attachments. The $* argument expands to a list of all the file names passed to the shell from Nautilus.

The paths of the files you have selected are passed to the script so that it can perform its tasks on those files. If you use a script while browsing a remote server, such as a Windows share or an FTP file system, the paths to the files you select are not passed to the script, but Nautilus sets these Environment variables, which can be used by the script:

  • NAUTILUS_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local).
  • NAUTILUS_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files.
  • NAUTILUS_SCRIPT_CURRENT_URI: URI for current location.
  • NAUTILUS_SCRIPT_WINDOW_GEOMETRY: position and size of current window.
  • This script will attach only local files to the new email message.

    This script does not populate your Send To field with any email addresses; you have to do that manually. It could, however, be extended to ask you for the email address of the person you want to send the files to and then send the message and its attachments to that person automatically. Obviously, you can do many more things with scripts, but this simple example demonstrates that you don't need a degree in computer science to get something simple happening.

    Next: Nautilus Extensions

Share    Print    Comments   

Comments

on Extending Nautilus with Scripts and Extensions

Note: Comments are owned by the poster. We are not responsible for their content.

relief joint

Posted by: Anonymous Coward on May 28, 2006 06:11 PM
[URL=http://painrelief.fanspace.com/index.htm] Pain relief [/URL]

  [URL=http://lowerbackpain.0pi.com/backpain.htm] Back Pain [/URL]

  [URL=http://painreliefproduct.guildspace.com] Pain relief [/URL]
[URL=http://painreliefmedic.friendpages.com] Pain relief [/URL]
[URL=http://nervepainrelief.jeeran.com/painrelief<nobr>.<wbr></nobr> htm] Nerve pain relief [/URL]

#

errata regarding /usr/share/nautilus-scripts

Posted by: Administrator on May 19, 2006 11:08 PM

Installing your script to<nobr> <wbr></nobr>/usr/share/nautilus-scripts will not automatically work for all users.



However, you can make scripts placed in this folder available to users by running nautilus-script-manager, which creates a symbolic link to your script in a user's ~/.gnome2/nautilus-scripts folder.



This only creates the link for the user who runs nautilus-script-manager though.



Steps to allow all new users to be able to use Nautilus Scripts from a global scripts folder:



1) Install your script to<nobr> <wbr></nobr>/usr/share/nautilus-scripts



2) Add a symbolic link to your script in the<nobr> <wbr></nobr>/etc/skel/.gnome2/nautilus-scripts folder.



mkdir<nobr> <wbr></nobr>/etc/skel/.gnome2

mkdir<nobr> <wbr></nobr>/etc/skel/.gnome2/nautilus-scripts

ln -s<nobr> <wbr></nobr>/usr/share/nautilus-scripts/myscript



This way all new users will have a link to your script created when they first login and they can delete the symlink if they don't want it anymore.



Alternatively you could add these lines to your<nobr> <wbr></nobr>/etc/skel/bashrc file:



if [ -x nautilus-script-manager ]

if [ ! -h<nobr> <wbr></nobr>.gnome2/nautilus-scripts/myscript ]

nautilus-script-manager enable myscript

fi

fi



This checks for and creates a symbolic link to your script, if it does not exist in the local user's<nobr> <wbr></nobr>.gnome2/nautilus-scripts folder, each time he logs in.



See man nautilus-script-manager for more info

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya