#!/bin/ksh VNCSERVER="vncserver" #The VNC Server command VNCVIEWER="vncviewer" #The VNC Viewer command VNCDISP=":9" #The display to run the VNC server on DEPTH="8" #The depth to run the VNC server at #The window manager command or startup script to run - make sure to use # the $VNCDISP variable to start the WM on the correct X display #WMANAGER="fvwm -d $VNCDISP" WMANAGER="wmaker --display $VNCDISP" echo "Starting VNC X at `date`" #The command to start the VNC server with VNCCMD="$VNCSERVER $VNCDISP -pixelformat rgb222 -geometry 640x480 -depth $DEPTH -alwaysshared" echo Starting VNC server... #Try to kill the VNC server in case it got stuck last time echo Trying to kill any old VNC processes... $VNCSERVER -kill :9 rm -f /tmp/.X11-unix/X9 #Try to run the VNC server; if it reports that it's already running, # try again (this happens sometimes when the remote viewer closes VNC) if ( $VNCCMD 2>&1 | grep "already running" ); then vncserver -kill :9 rm -f /tmp/.X11-unix/X9 $VNCCMD fi echo "Done: VNC's PID is `cat ~/.vnc/*:9.pid`" echo Starting VNC viewer... #Start the VNC viewer on the local display vncviewer -nocursorshape -passwd .vnc/passwd -geometry 640x480+0+0 $VNCDISP & #Start the window manager - not backgrounded echo starting "$WMANAGER" $WMANAGER #When we get here, we know the window manager has been exited echo X is done, killing vncviewer pid `cat ~/.vnc/*:9.pid` vncserver -kill $VNCDISP