rendered paste body#!/bin/sh
# usage: rx <host>:<xdisplay>
# e.g.: rx snoopy.peanuts.com:0
#SCALE='-scale 9/10'
OPTIONS="$SCALE -localhost -norc -notruecolor"
host=`echo $1 | awk -F: '{print $1}'`
disp=`echo $1 | awk -F: '{print $2}'`
if [ "x$disp" = "x" ]; then disp=0; fi
cmd="ps ax | grep -v grep | grep -q x11vnc && killall x11vnc ; x11vnc -display :$disp -nap -localhost -o $HOME/.vnc/vnclog $OPTIONS"
enc="copyrect tight hextile zlib corre rre raw"
ssh -f -c blowfish -L 5900:localhost:5900 $host "$cmd"
#wait for vnc server to be ready
until $(ssh $host netstat -an | grep 5900 | grep -q LISTEN); do sleep 1; done
vncviewer localhost:0