Skip to content

開機自動運行VNC程式(Jessie)

此文章用於把VNC設置成開機啟動,如此方法不行,則可以參考另一篇設置成開機服務的文章。

  1. Install the VNC server.
    sudo apt-get install tightvncserver
  2. Launch vncserver for the first time to set up a password.
    vncserver :1
  3. Create a file as /etc/init.d/vncserver (be sure to modify the USER, GEOMETRY, NAME, etc.)
  4. sudo chmod +x /etc/init.d/vncserver
  5. sudo update-rc.d vncserver defaults

以下是/etc/init.d/vncserver的內容:


/etc/init.d/vncserver

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     S
# Default-Stop:      0 6
### END INIT INFO

PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="pi"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"

# Color depth (between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.
NAME="my-vnc-server"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac

exit 0
Published inRaspberry Pi

Be First to Comment

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *