The -display WAIT
option makes x11vnc wait until a VNC viewer is connected before attaching to the
X display. Additionally it can be used to run an external command that returns the
DISPLAY and XAUTHORITY data.
We provide some useful builtin ones (FINDDISPLAY and FINDCREATEDISPLAY below), but
in principle one could supply
"-display WAIT:cmd=/path/to/find_display" where the script find_display
might look something like:
#!/bin/sh
PATH=$PATH:/bin:/usr/bin:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin
export PATH
user=$1
if [ "X$user" = "X" ]; then
user=$USER
fi
if [ "X$user" = "X" ]; then
user=$LOGNAME
fi
if [ "X$user" = "X" ]; then
echo ""
exit 1
fi
display=`who | grep "^${user}[ ][ ]*:[0-9]" | head -1 | awk '{print $2}'`
if [ "X$display" = "X" ]; then
display=`who | grep "^${user}[ ]" | awk '{print $NF}' | grep '(:[0-9]' | sed -e 's/[()]//g' | head -1`
if [ "X$display" = "X" ]; then
echo ""
exit 1
fi
fi
echo "DISPLAY=$display"
xauth extract - "$display" 2>/dev/null
exit 0
A default script somewhat like the above is used
under "-display WAIT:cmd=FINDDISPLAY"
(same as -find)
(use "WAIT:cmd=FINDDISPLAY-print" to print out the script).
The format for any such command is that it returns DISPLAY=:disp
as the first line and any remaining lines are either
XAUTHORITY=file or raw xauth data (the above example does
the latter). If applicable (-unixpw mode), the
program is run as the Unix user name who logged in.