Tuesday, November 30, 2010

Opening nfs:// URLs in Gnome

By default, Gnome will not handle NFS URLs, but a handler can be registered. First, enable NFS and setup autofs to handle dynamic NFS links (google on how to do this). I am assuming that your auto NFS mounter is setup to use /net/ for NFS.

Next, create a script to convert nfs:// to /net/:
/usr/local/bin/nfs-handler

#!/bin/bash

NFSURL=$1

if [ -z "$NFSURL" ]; then
 echo 'URL required' >&2
 exit 2
fi

NFSURL=`echo $NFSURL | sed 's~^nfs://~/net/~'`

nautilus "$NFSURL"

Now register this with gnome (run from a terminal):

gconftool-2 --set --type=string /desktop/gnome/url-handlers/nfs/command '/usr/local/bin/nfs-handler "%s"'
gconftool-2 --set --type=bool /desktop/gnome/url-handlers/nfs/need-terminal false
gconftool-2 --set --type=bool /desktop/gnome/url-handlers/nfs/enabled true

That is it. Test using:xdg-open "nfs://somecomputer/somemountpoint"


© Copyright 2007 - Andrew Robinson. Please feel free to use in your applications under the LGPL license (http://www.gnu.org/licenses/lgpl.html).

No comments: