[转帖][分享]在gnome中用rox文件管理器代替Nautilus!

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
XDG3669
帖子: 380
注册时间: 2006-07-10 22:50

[转帖][分享]在gnome中用rox文件管理器代替Nautilus!

#1

帖子 XDG3669 » 2008-01-17 18:13

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

代码: 全选

sudo apt-get install rox-filer
2: Set nautilus aside

代码: 全选

sudo mv /usr/bin/nautilus /usr/bin/nautilus.bin
3: Save this script as /usr/bin/nautilus (you must be root)

代码: 全选

#!/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

代码: 全选

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.

代码: 全选

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)

代码: 全选

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

代码: 全选

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.
__________________
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#2

帖子 eexpress » 2008-01-17 23:07

gnome绑定nautilus,不爽。
● 鸣学
头像
forrid
帖子: 659
注册时间: 2007-04-23 17:40

#3

帖子 forrid » 2008-01-18 16:28

我的nautilus老是出问题,现在在用rox

吾生也有涯,而知也无涯,以有涯随无涯,SB啊~~~~~~~~~~
头像
thomasxie
帖子: 317
注册时间: 2009-11-22 15:29
联系:

Re: [转帖][分享]在gnome中用rox文件管理器代替Nautilus!

#4

帖子 thomasxie » 2011-07-11 22:59

:em11
时间就像一张网,你撒在那里,你的收获就在那里。
回复