I use x11vnc instead, due to some problems on other PCs (not the Raspberry Pi). Do sudo apt-get install x11vnc, then create (touch /etc/init.d/myx11vnc) and edit /etc/init.d/myx11vnc and put in it:
[CODE] ---------------
#!/bin/sh
# /etc/init.d/myx11vnc: set up the vnc server
### BEGIN INIT INFO
# Provides: x11vnc
# Required-Start: $remote_fs x11-common
# Required-Stop: $remote_fs x11-common
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
set -e
PATH=/usr/bin:/usr/sbin:/bin:/sbin
COMMAND="/usr/bin/x11vnc"
NAME="x11vnc"
THISSCRIPT="/etc/init.d/myx11vnc"
. /lib/lsb/init-functions
if [ -f /etc/default/rcS ]; then
. /etc/default/rcS
fi
if [ ! -e $DISPLAY ]; then
export DISPLAY=":0"
fi
if [ -e /root/.vnc/passwd ]; then
PASSFILE="/root/.vnc/passwd"
fi
VERBOSE="yes"
if [ "$VERBOSE" != no ]; then
echo "Executing $NAME $1..." >> /var/log/x11vnc-boot.log
fi
case "$1" in
status)
echo "$0 checking status of $NAME..."
if [ ! -z "$(pidof $NAME)" ]; then
echo "checking..."
x11vncPID="$(pidof $NAME)"
onePID="${x11vncPID%%[ ]*}" # ensure only ONE pid!
if [ -d /proc/$onePID ]; then
echo "found PID = $onePID, so it's running."
x11Link="$(readlink /proc/$onePID/exe)"
echo "/proc link is $x11Link"
if [ $x11Link = $COMMAND ]; then
echo "$NAME is RUNNING."
echo "STATUS: $NAME is RUNNING." >> /var/log/x11vnc-boot.log
fi
fi
else
echo "$NAME has NO PID."
echo "STATUS: $NAME is NOT RUNNING." >> /var/log/x11vnc-boot.log
fi
;;
start)
#x11vncPID="$(pidof $NAME)"
if [ -z "$(pidof $NAME)" ]; then
if [ "$VERBOSE" != no ]; then
log_begin_msg "Setting up $NAME..."
echo "Setting up $NAME..." >> /var/log/x11vnc-boot.log
fi
# uncomment this if you have setup .x11vncrc correctly...
#if [ -e /root/.x11vncrc ]; then
# if [ "$VERBOSE" != no ]; then
# log_begin_msg "Using .x11vncrc for $NAME..."
# fi
# ARGS="-o /var/log/x11vnc.log -display $DISPLAY"
# $COMMAND $ARGS 2>/dev/null 1>&2 &
#else
ARGS="-norc -auth /var/run/lightdm/root/:0 -forever -shared -allow 192.168.1. -geometry 1900x980 -passwd MyX11VNCPasswd -o /var/log/x11vnc.log -display $DISPLAY"
$COMMAND $ARGS 2>/dev/null 1>&2 &
#fi
if [ ! -z "$(pidof $NAME)" ]; then
echo "$NAME PID=$(pidof $NAME) started with $ARGS." >> /var/log/x11vnc-boot.log
fi
if [ "$VERBOSE" != no ]; then
log_end_msg 0
fi
fi
exit 0
;;
restart|reload|force-reload)
$THISSCRIPT start
;;
stop)
# :
echo "$0 checking status of $NAME..."
if [ ! -z "$(pidof $NAME)" ]; then
echo "checking..."
x11vncPID="$(pidof $NAME)"
onePID="${x11vncPID%%[ ]*}" # ensure only ONE pid!
if [ -d /proc/$onePID ]; then
echo "found PID = $onePID, so it's running."
x11Link="$(readlink /proc/$onePID/exe)"
echo "/proc link is $x11Link"
if [ $x11Link = $COMMAND ]; then
kill -s SIGTERM $onePID
# echo "$NAME is RUNNING."
fi
fi
fi
;;
*)
log_success_msg "Usage: $THISSCRIPT {start|stop|status|restart|reload|force-reload}"
exit 1
;;
esac
exit 0
[/CODE] -------------------
Next do sudo update-rc.d myx11vnc defaults so that the myx11vnc script will run when you do a reboot.
The following script (startupx11vnc.sh) should work for you as well:
#!/bin/bash
#
# Start x11vnc the hard way...
#
#
if [ ! -e $DISPLAY ]; then
export DISPLAY=":0"
fi
#
if [ -z $DISPLAY ]; then
export DISPLAY=":0"
fi
#
COMMAND="sudo x11vnc "
ARGS="-norc -auth /var/run/lightdm/root/:0 -forever -shared -allow 192.168.1. -geometry 1920x1080 -passwd MyX11vncPasswd -o /var/log/x11vnc.log -display $DISPLAY"
#
$COMMAND $ARGS 2>/dev/null 1>&2 &
#
exit 0
#
tightvncserver :1
, nottightvncserver:1
. Either way, Raspbian now comes with a RealVNC server licence (enable it throughraspi-config
) which is exceedingly fast.