Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old July 11th, 2005   #1
Laurent Cazalet
5 Cups of Ubuntu
 
Join Date: Apr 2005
Location: Brussels
Beans: 21
Send a message via Yahoo to Laurent Cazalet
Cool HOWTO: replace Nautilus by Rox filer in Gnome

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
Code:
sudo apt-get install rox-filer
2: Set nautilus aside
Code:
sudo mv /usr/bin/nautilus /usr/bin/nautilus.bin
3: Save this script as /usr/bin/nautilus (you must be root)
Code:
#!/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
4: change ownership and make this script executable
Code:
sudo chown root.root /usr/bin/nautilus
sudo chmod a+x /usr/bin/nautilus
5: Add this to ~/.gnomerc
So that changes affect only users that want it.
Code:
NAUTILUS_REPLACEMENT=/usr/bin/rox
TRASHDIR=$HOME/.Trash
export TRASHDIR NAUTILUS_REPLACEMENT
Advanced topic
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)
Code:
MOUNTROOT=$HOME/mnt
export MOUNTROOT
Configure your network drives from the Gnome interface, as you would normally do.

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
Code:
gnomevfs-umount $HOME/mnt/<server>
(I added a link to this command to the mountpoint send-to of Rox filer)

Usual disclaimer: I'm not responsible if you **** your system up.
Laurent Cazalet is offline   Reply With Quote
Old July 11th, 2005   #2
sapo
Fresh Brewed Ubuntu
 
sapo's Avatar
 
Join Date: Mar 2005
Location: Brazil
Beans: 1,178
Ubuntu 7.04 Feisty Fawn
Send a message via MSN to sapo
Re: HOWTO: replace Nautilus by Rox filer in Gnome

whats the difference between rox and nautilus? where can i read more about it? i really dont know this app...
__________________
Yet Another Coding Blog
Flash Host
sapo is offline   Reply With Quote
Old July 11th, 2005   #3
bored2k
Skinny Extra Sweet Ubuntu
 
bored2k's Avatar
 
Join Date: Feb 2005
My beans are hidden!
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Quote:
Originally Posted by sapo
whats the difference between rox and nautilus? where can i read more about it? i really dont know this app...
I know rox is faster than the speed of light, but, I'm also curious (i never used rox.. just a bit).

Why should I use it instead of the beloved nautilus ? Why is it so much better ?
__________________
Sylvia: Look at what you've done to him!
Christof: I have given Truman the chance to lead a normal life. The world, the place you live in, is the sick place.
bored2k is offline   Reply With Quote
Old July 11th, 2005   #4
cutOff
Way Too Much Ubuntu
 
Join Date: Dec 2004
Location: Barcelona
Beans: 274
Ubuntu 8.04 Hardy Heron
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Quote:
Originally Posted by bored2k
Why should I use it instead of the beloved nautilus ? Why is it so much better ?
Not a flame but I wonder the same thing.
__________________
Registered Linux User #371167
cutOff is offline   Reply With Quote
Old July 11th, 2005   #5
Mr. Electric Wizard
Ubuntu Extra Shot
 
Mr. Electric Wizard's Avatar
 
Join Date: Jun 2005
Location: Houston, Texas
Beans: 352
Re: HOWTO: replace Nautilus by Rox filer in Gnome

The only thing I don't like about Nautilus is the fact that it opens a new "window" when you drill down through a directory.
It would be nice if you could keep this from happening and have only the "active" window open.
I hate when I drill down, the child directory is always really tiny, and I have to resize it...
Mr. Electric Wizard is offline   Reply With Quote
Old July 11th, 2005   #6
Heliode
A Carafe of Ubuntu
 
Heliode's Avatar
 
Join Date: Mar 2005
Beans: 143
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Quote:
Originally Posted by Mr. Electric Wizard
The only thing I don't like about Nautilus is the fact that it opens a new "window" when you drill down through a directory.
It would be nice if you could keep this from happening and have only the "active" window open.
I hate when I drill down, the child directory is always really tiny, and I have to resize it...
Open nautilus -> Edit -> Preferences -> Behaviour -> Select 'Always open in browser'
et voila!

I might have some of the names wrong (since I run Ubuntu in Dutch) but you should be able to figure it out. Also, when you have that, you can set the left panel to 'tree' so you get something that looks like Explorer on Windows.
__________________
"Windows is something to overcome"

Howto's by me:
Tweak firefox! (URL now works..)
Backup/Restore your system!
Avoid having to reboot


Compentux.org
, the Linux Tip & Howto gathering initiative!
Heliode is offline   Reply With Quote
Old July 11th, 2005   #7
bored2k
Skinny Extra Sweet Ubuntu
 
bored2k's Avatar
 
Join Date: Feb 2005
My beans are hidden!
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Quote:
Originally Posted by Heliode
Open nautilus -> Edit -> Preferences -> Behaviour -> Select 'Always open in browser'
et voila!

I might have some of the names wrong (since I run Ubuntu in Dutch) but you should be able to figure it out. Also, when you have that, you can set the left panel to 'tree' so you get something that looks like Explorer on Windows.
Exactly. That's the "fix" for Spatial nautilus introduced in Gnome 2.6.

Any other reason why I should use rox ?
__________________
Sylvia: Look at what you've done to him!
Christof: I have given Truman the chance to lead a normal life. The world, the place you live in, is the sick place.
bored2k is offline   Reply With Quote
Old July 11th, 2005   #8
tread
Extra Foam Sugar Free Ubuntu
 
Join Date: Apr 2005
Beans: 737
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Also, are file extensions registered as well as in nautilus?
tread is offline   Reply With Quote
Old July 11th, 2005   #9
regeya
A Carafe of Ubuntu
 
regeya's Avatar
 
Join Date: Oct 2004
Beans: 98
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Quote:
Originally Posted by bored2k
Exactly. That's the "fix" for Spatial nautilus introduced in Gnome 2.6.

Any other reason why I should use rox ?
Well, I'm not considering the move, but ROX is fast as lightning. It's not the prettiest thing, but it's fast as lightning.

I don't see the point of using ROX unless you want to commit to the full-meal deal: ROX-Desktop, the Pinboard, App dirs, etc. Otherwise it's just a second-rate Finder-ish filemanager, IMHO.

This might be a nice thing to do with xfce on a low-resources machine, maybe. *shrug*
regeya is offline   Reply With Quote
Old July 12th, 2005   #10
Laurent Cazalet
5 Cups of Ubuntu
 
Join Date: Apr 2005
Location: Brussels
Beans: 21
Send a message via Yahoo to Laurent Cazalet
Re: HOWTO: replace Nautilus by Rox filer in Gnome

Well...
This howto is not meant to be a Rox filer advocacy. Look at http://rox.sourceforge.net/phpwiki/index.php/ROX-Filer for features.
It's meant to help people who like the fast, handy, flexible Rox filer to have the choice to use it instead of Nautilus. I just wanted to publish my script and give them the choice.

For the rest, it's all a matter of personal taste and perception.
My subjective perception is: not only Rox filer is fast as hell and uses drag and drop extensively, but it also comes with a lot of handy features and is a full gtk2 application (integrating pretty nicely with gnome desktop), which make you forget the command line for ever. And Nautilus is awkard and takes way too long to open and work with, for an application that should be unobstrusive.
On slow machines, you really feel the difference, and if Gnome in itself is usable and a slick integrated environment, Nautilus is a real hassle to work with.

The pros I find in Rox filer may be cons to you. It's just like if you asked "why should I use xfce instead of gnome?". Just try it, this is the freedom of choice.
Laurent Cazalet is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:36 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry