虽然linuxer们坚持认为一个terminal就够了,但这不是我的菜,还是要搞出桌面才够爽。
vnc server启动时,会调用“~/.vnc/xstartup”进行初始化,我们的任务就是在这里启动桌面环境。
ubuntu支持两种桌面环境:unity与gnome,(unity是对gnome的一种深度定制)
还写以选择安装一种轻量级桌面环境,xfce4。
原来计划搞定三种桌面环境,最终却没搞定ubuntu 14.04上默认支持的unity :(
不管怎么,三种方式都放到下面的脚本中了,unity仅作参考了。
点击(此处)折叠或打开
-
#!/bin/sh
-
-
# DESK_TYPE=xfce
-
DESK_TYPE=gnome
-
# DESK_TYPE=unity
-
-
# Uncomment the following two lines for normal desktop:
-
unset SESSION_MANAGER
-
unset DBUS_SESSION_BUS_ADDRESS
-
# exec /etc/X11/xinit/xinitrc
-
-
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
-
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
-
xsetroot -solid grey
-
vncconfig -iconic &
-
# x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
-
# x-window-manager &
-
-
echo $DESK_TYPE
-
# xfce desktop
-
if test $DESK_TYPE = xfce; then
-
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
-
x-session=-manager &
-
xfdesktop & xfce4-panel &
-
xfce4-menu-plugin &
-
xfsettingsd &
-
xfconfd i&
-
xfwm4&
-
fi
-
-
# gnome desktop
-
if test $DESK_TYPE = gnome; then
-
gnome-session &
-
gnome-panel &
-
gnome-settings-daemon &
-
metacity &
-
nautilus -n &
-
gnome-terminal &
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings panel-main-menu "['
F1']"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings maximize "['
KP_5']"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings unmaximize "['
F5']"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings show-desktop "['
d']"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-applications "['
Tab']"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-group "['
Above_Tab']"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-input-source "[]"
-
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "[]"
-
/usr/bin/gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "['
t']"
-
fi
-
-
# unity desktop
-
if test $DESK_TYPE = unity; then
-
export DESKTOP_SESSION=ubuntu
-
export GDMSESSION=ubuntu
-
export STARTUP="/usr/bin/gnome-session --session=ubuntu"
-
$STARTUP &
- fi
vnc配置好后,如果希望开机启动,可以建立文件“/etc/vncserver/vncservers.conf”用来配置需要启动的server
点击(此处)折叠或打开
-
VNCSERVERS="1:hao-64 11:hao-64 12:hao-64 13:hao-64 14:hao-64 15:hao-64"
-
VNCSERVERARGS[1]="-geometry 1024x768"
-
VNCSERVERARGS[11]="-geometry 1680x1050"
-
VNCSERVERARGS[12]="-geometry 1366x768"
-
VNCSERVERARGS[13]="-geometry 1280x1024"
-
VNCSERVERARGS[14]="-geometry 1024x768"
- VNCSERVERARGS[15]="-geometry 800x600"
点击(此处)折叠或打开
-
#!/bin/bash
-
-
unset VNCSERVERARGS
-
VNCSERVERS=""
-
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
-
prog=$"VNC server"
-
start() {
-
. /lib/lsb/init-functions
-
REQ_USER=$2
-
echo -n $"Starting $prog: "
-
ulimit -S -c 0 >/dev/null 2>&1
-
RETVAL=0
-
for display in ${VNCSERVERS}
-
do
-
export USER="${display##*:}"
-
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
-
echo -n "${display} "
-
unset BASH_ENV ENV
-
DISP="${display%%:*}"
-
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
-
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
-
fi
-
done
-
}
-
stop() {
-
. /lib/lsb/init-functions
-
REQ_USER=$2
-
echo -n $"Shutting down VNCServer: "
-
for display in ${VNCSERVERS}
-
do
-
export USER="${display##*:}"
-
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
-
echo -n "${display} "
-
unset BASH_ENV ENV
-
export USER="${display##*:}"
-
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
-
fi
-
done
-
echo -e "\n"
-
echo "VNCServer Stopped"
-
}
-
case "$1" in
-
start)
-
start $@
-
;;
-
stop)
-
stop $@
-
;;
-
restart|reload)
-
stop $@
-
sleep 3
-
start $@
-
;;
-
condrestart)
-
if [ -f /var/lock/subsys/vncserver ]; then
-
stop $@
-
sleep 3
-
start $@
-
fi
-
;;
-
status)
-
status Xvnc
-
;;
-
*)
-
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
-
exit 1
- esac
最后,重启系统