2012年2月25日星期六

Nautilus and Gnome

Gnome: 采用脚掌印标志,单词对应中文翻译为“地精”,它是GNU Network Object Model Envrionment的首字母缩写,它是一种完全由免费和开源软件组成的桌面环境和用户图形界面,属于GNU Project的一部分。
GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. It is composed entirely of free and open source software. It is an international project that includes creating software development frameworks, selecting application software for the desktop, and working on the programs that manage application launching, file handling, and window and task management. 
GNOME is part of the GNU Project and can be used with various Unix-like operating systems, most notably Linux and as part of OpenSolaris Desktop.  
                                                                                   摘自wikipedia 
Nautilus:Gnome桌面环境下的文件管理器(file manager for Gnome desktop)
Nautilus功能扩展:
Nautilus can be extended in two main ways. Through Nautilus extensions, and through scripts.
Nautilus扩展说明档参见这里
扩展实例:通过script实现右键添加快速启动Terminal功能(另外一种实现方法参见这里
提示:Nautilus scripts文件必须存放在~/.gnome2/nautilus-scripts ($HOME/.gnome2/nautilus-scripts)路径下。
1、通过gedit创建新文件"Open Terminal Here"

$ gedit "$HOME/.gnome2/nautilus-scripts/Open Terminal Here"

2、在新文件中写入如下代码:

#!/bin/bash
# From Chris Picton
# Replaces a Script by Martin Enlund
# Modified to work with spaces in path by Christophe Combelles
 
# This script either opens in the current directory,
# or in the selected directory
 
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
     dir="$base"
else
     while [ ! -z "$1" -a ! -d "$base/$1" ]; do shift; done
     dir="$base/$1"
fi
 
gnome-terminal --working-directory="$dir"
代码说明:NAUTILUS_SCRIPT_CURRENT_URI variable gives current location for directory. NAUTILUS_SCRIPT_SELECTED_FILE_PATHS sets a newline-delimited paths for selected files.

3、保存并关闭文件,设定权限:

$ chmod +x "$HOME/.gnome2/nautilus-scripts/Open Terminal Here"

设定好权限后便直接可以使用,无需重启nautilus(以下图片摘自网络,年代较老)
随便点击鼠标右键,右键菜单中多了Scripts项,选择Open Shell Prompt,打开终端。
Fig.01: Open Shell Prompt Here Script
Fig.01: Open Shell Prompt Here Script

And terminal will open at sg1 directory:
Fig.02: Nautilus script opened a terminal
Fig.02: Nautilus script opened a terminal

没有评论: