--- trunk/webthumb 2008/02/06 23:34:35 63 +++ trunk/webthumb 2008/02/06 23:45:58 64 @@ -33,7 +33,7 @@ # and then resize it to (comment out to disable) #RESIZE=200x -# turn locally visible Xnest server to watch progress +# turn locally visible server to watch progress DEBUG=0 test ! -z "$3" && DEBUG=1 @@ -81,20 +81,30 @@ exit 1 fi -echo "starting X server $XSERVER" +DISPLAY_PORT=6042 -export DISPLAY=:42 +while netstat -ln | grep ":$DISPLAY_PORT " >/dev/null ; do + DISPLAY_PORT=`expr $DISPLAY_PORT + 1` +done + +DISPLAY=:`expr $DISPLAY_PORT - 6000` +echo "using DISPLAY=$DISPLAY" if [ "$DEBUG" == 1 ] ; then echo "using locally visible debug server on $LOCAL_DISPLAY" - Xnest -display $LOCAL_DISPLAY -ac -geometry ${W}x${H} -depth 24 $DISPLAY 2>/dev/null & + DISPLAY=$LOCAL_DISPLAY Xephyr -ac -screen ${W}x${H}x24 $DISPLAY 2>/dev/null & else echo "starting $XSERVER" $XSERVER -ac -screen 0 ${W}x${H}x24 $DISPLAY 2>/dev/null & fi +if [ -z "$!" ] ; then + echo "ABORT: can't start X server!" + exit +fi XSERVER_PID=$! + echo "X server pid $XSERVER_PID" function kill_x_server() {