I like Gnome, but I'm always annoyed by Nautilus. And when you use Gnome, Nautilus gets in your way all the time, while I prefer a lot the agile Rox filer.
Here's a way to combine the best of both.
This script aims to transparently use Rox filer instead of Nautilus.
This HOWTO also gives a method to mount Gnome-VFS drives onto the system so that they are available to non-Gnome programs (like Rox filer).
Objective:
Rox filer (or another file manager) runs as a transparent replacement of Nautilus everytime the system calls /usr/bin/nautilus. This is a user-specific hack. It doens't affect other users of the system.
In particular in the following cases
- open folder from Places menu and panels
- open automatically mounted media (CDROM, usb drive etc...)
- open trashcan clicking from Gnome panel (if TRASHDIR is set)
- "open folder" when called from Search dialog box
- open network drives (if Fuse and another tools are installed, see advanced topic below)
Opens normally Nautilus if:
- the environment variable NAUTILUS_REPLACEMENT is not set
- Nautilus browser mode is requested (--browse flag) (independant from settings)
- click on computer, network servers entries in Places menu
- open network drives from Places menu (if fuse not configured)
- click on trash applet and env. var. TRASHDIR is not set
- Nautilus is configured to draw the desktop and you click on desktop icons (not a feature of the script, though
As a side note,
- You can still have Nautilus draw the desktop
- drag-and-drop to trash applet works okay from Rox.
But...
- under Metacity (standard Gnome window manager), Rox filer often opens new windows beneath the active window. workarounds if it's to annoying: use xfwm4 or openbox window manager.
- (minor) Opening Home Folder from the Places menu works fine but gives visual notification timeout
- if Nautilus gets updated, the script will have to be reinstalled.
Installation
Five easy steps
1: install rox filer
代码: 全选
sudo apt-get install rox-filer
代码: 全选
sudo mv /usr/bin/nautilus /usr/bin/nautilus.bin
代码: 全选
#!/bin/bash
#replacement/wrapper for nautilus
# also mounts network drives using gnomevfs-mount (using fuse)
# doesn't check if already mounted
NAUTILUS=/usr/bin/nautilus.bin
DEBUG=0
# backup our args list
ARGS=$@
ARGSCOUNT=$#
# call nautilus, with all args received in input
function run_nautilus() {
[ $DEBUG != 0 ] && echo "OUT: Running Nautilus" >> $HOME/nautilus_wrapper.log
exec $NAUTILUS $ARGS
}
# calls the replacement, only arg must be an existing dir
function run_replacement() {
[ $DEBUG != 0 ] && echo "OUT: Running $NAUTILUS_REPLACEMENT. Args: '$@'" >> $HOME/nautilus_wrapper.log
exec $NAUTILUS_REPLACEMENT $@
}
# make a directory where to mount our network drive
function makemountdir() {
# get the server part of the URI
SERVER="`echo \"$1\" | sed -e 's/^(https\|http\|sftp\|ftp\|ssh)//' -e 's/:\/\///' -e 's/.*@//' -e 's/\/.*//'`"
MOUNTDIR=$MOUNTROOT/$SERVER
[ $DEBUG != 0 ] && echo "...: Mounting $1 on $MOUNTDIR" >> $HOME/nautilus_wrapper.log
mkdir -p $MOUNTDIR
}
[ $DEBUG != 0 ] && echo "IN: $0 invoked with '$@'" >> $HOME/nautilus_wrapper.log
# if this user didn't configure a replacement, just give way to nautilus
if [ -z "$NAUTILUS_REPLACEMENT" ]; then
run_nautilus
fi
# loop through all args to see if one of them requires
# that we run nautilus
while [ -n "$1" ]; do
case "$1" in
-c|--check) ;; #ignore
-g) shift ;; #ignore, and ignore next one
--geometry) ;; #ignore
--no-desktop) ;; #ignore
--sm-disable) ;; #ignore
-n|--no-default-window)
# run nautilus if not asked for anything else
#if this is the only argument, start nautilus
# this happens when nautilus is asked to draw the desktop
if [ $ARGSCOUNT == 1 ]; then
run_nautilus
fi;;
--sm-client-id) run_nautilus;;
-? | --help) run_nautilus;;
--usage) run_nautilus;;
--browser) run_nautilus;;
-q|--quit) run_nautilus;;
computer*) run_nautilus;;
network*) run_nautilus;;
trash*)
if [ -z "$TRASHDIR" ]; then
run_nautilus
else
run_replacement "$TRASHDIR"
fi;;
file*)
# turn the file:/// URI into a filesystem path,
FILE="`echo \"$1\" | sed -e 's/^file:\/\///' -e 's/%20/\ /g'`"
run_replacement "$FILE";;
ftp* | sftp* | http* | smb* | ssh* )
#if we can mount this network dir through
# Fuse and gnomevfs-mount, do it
if [ -e /usr/bin/gnomevfs-mount ] && [ -n "$MOUNTROOT" ]; then
makemountdir "$1"
/usr/bin/gnomevfs-mount "$1" "$MOUNTDIR"
run_replacement "$MOUNTDIR"
else
run_nautilus
fi;;
*)
# unknown arg. if it's a filesystem object, use replacement
# otherwise give up and start nautilus
if [ -e "$1" ]; then
run_replacement "$1"
else
[ $DEBUG != 0 ] && gmessage "$0 $ARGS" &
run_nautilus
fi;;
esac
shift
done
#default: open home dir
run_replacement $HOME
exit 0
代码: 全选
sudo chown root.root /usr/bin/nautilus
sudo chmod a+x /usr/bin/nautilus
So that changes affect only users that want it.
代码: 全选
NAUTILUS_REPLACEMENT=/usr/bin/rox
TRASHDIR=$HOME/.Trash
export TRASHDIR NAUTILUS_REPLACEMENT
Icing on the cake: Fully take advantage of Nautilus network drives (using gnome-vfs) with any non-Gnome programs like Rox filer.
Not a full how-to, but it should be straightforward.
- compile and install fuse kernel module and library (http://fuse.sourceforge.net/)
(haven't tested the ubuntu package)
- compile and install gnomevfs-mount from http://gnomedesktop.org/node/1981/31756
be sure to --enable-keyring when running ./configure
(ask me for a deb package if you need to)
- add this to your ~/.gnomerc (create it if it doesn't exist)
代码: 全选
MOUNTROOT=$HOME/mnt
export MOUNTROOT
Enjoy automounting of those drives to $HOME/mnt/<server>
Clicking on the net drive from the Places menu mounts the drive and opens
rox-filer at the correct location.
To unmount those drives, call
代码: 全选
gnomevfs-umount $HOME/mnt/<server>
Usual disclaimer: I'm not responsible if you **** your system up.
__________________