#!/bin/sh
VNCSRV=":3"
VNCGEO="1024x768"
EXTDSP=":0.1"


# Fire up vncserver and give it some time for things to settle
vncserver -geometry $VNCGEO $VNCSRV &
sleep 10

# "remote" viewer i.e. gets to the beamer
vncviewer -fullscreen -shared -viewonly  -passwd $HOME/.vnc/passwd localhost$VNCSRV -display $EXTDSP &

### enable the mouse moving to the external display
#x2vnc -shared -east -passwdfile $HOME/.vnc/passwd localhost$VNCSRV &
###

# local viewer
xvncviewer -passwd $HOME/.vnc/passwd -shared $VNCSRV &

# fire up acrobat on the external display together with the file
acroread -display $VNCSRV "$@"


# kill all clients nicely, shut down the server, remove logs/pids if
# they exist (which sometimes seems to happen)
killall vncviewer
killall xvncviewer
sleep 2
vncserver -kill $VNCSRV
rm -f $HOME/.vnc/*.log
rm -f $HOME/.vnc/*.pid

