#!/bin/sh remote_host=${1:-blackboard} remote_display=${2:-:0} local_display=${3:-0} direct_connection() { port=$((5900 + local_display)) ssh -o ControlPath=none -n \ -L $port:localhost:$port "$remote_host" 'x11vnc -nopw -ncache -ncache_cr -localhost -display :0' & pid=$! sleep 1 # surrender race xvncviewer -encodings "copyrect tight zrle hextile" localhost:0 kill $pid } reverse_connection() { port=5500 xvncviewer -fullscreen -encodings "copyrect tight zrle hextile" -listen & pid=$! ssh -o ControlPath=none \ -R $port:localhost:$port "$remote_host" \ "x11vnc -nopw -localhost -display ${remote_display} -coe localhost:$port -rfbport 0" \ >/dev/null 2>&1 kill $pid } if [ "$USE_DIRECT_CONNECTION" ]; then direct_connection else reverse_connection fi