当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 4 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : [转帖][分享]在gnome中用rox文件管理器代替Nautilus!
帖子发表于 : 2008-01-17 18:13 

注册: 2006-07-10 22:50
帖子: 380
送出感谢: 0 次
接收感谢: 0 次
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.
__________________


页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2008-01-17 23:07 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 272
gnome绑定nautilus,不爽。


_________________
● 鸣学


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2008-01-18 16:28 
头像

注册: 2007-04-23 17:40
帖子: 659
送出感谢: 0 次
接收感谢: 0 次
我的nautilus老是出问题,现在在用rox


_________________

吾生也有涯,而知也无涯,以有涯随无涯,SB啊~~~~~~~~~~


页首
 用户资料  
 
4 楼 
 文章标题 : Re: [转帖][分享]在gnome中用rox文件管理器代替Nautilus!
帖子发表于 : 2011-07-11 22:59 
头像

注册: 2009-11-22 15:29
帖子: 317
送出感谢: 1
接收感谢: 0 次
:em11


_________________
时间就像一张网,你撒在那里,你的收获就在那里。


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 4 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 3 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译