2014年5月15日

nautilus-open-as-root ubuntu 14.04

在ubuntu 14.04中又找不到nautilus-open-as-root套件,想把它裝起來,找到做法,記錄一下
1.在使用者的家目錄
$cd ~/.local/share/nautilus/scripts
$touch open-as-root
$chmod 755 open-as-root
$vim open-as-root
加入以下內容

#!/bin/bash
#
# this code will determine exactly the path and the type of object,
# then it will decide use gedit or nautilus to open it by ROOT permission
#
# Determine the path
if [ -e -n $1 ]; then
obj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
else
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
obj="$base/${1##*/}"
fi
# Determine the type and run as ROOT
if [ -f "$obj" ]; then
gksu gedit "$obj"
elif [ -d "$obj" ]; then
gksu nautilus "$obj"
fi
exit 0

另一做法(事實上做法差不多)

沒有留言: