#!/u/bin/bsh
#startx_plus, FreeBSD4.5
set -f
#u==user s==sys,server c==client
#bindir=/usr/X11R6/bin
uc_rc=$HOME/.xinitrc
us_rc=$HOME/.xserverrc
sc_rc=/usr/X11R6/lib/X11/xinit/xinitrc
ss_rc=/usr/X11R6/lib/X11/xinit/xserverrc
[ -s $sc_rc ] && cargs=$sc_rc
[ -s $uc_rc ] && cargs=$uc_rc
[ -s $ss_rc ] && sargs=$ss_rc
[ -s $us_rc ] && sargs=$us_rc
args=cargs
for A in $@
do
[ "$A" == -- ] && args=sargs continue
$args="${{args} $A"
done
# ---------------------------------------------------
sargs=$sargs
ifset sargs || {
pids=$( ps -wajx | grep '[/ ]xinit .*--' | cut -d' ' -f2 )
ps -wajx | grep ' :[0-9]' |
while read - - ppid - - - - - - cmd
do
expr " $pids " :: " $ppid " || continue
expr "$cmd" :dpy '/[^ ]%{1,} %(:[0-9]%)' || continue
expr "$cmd" :cmd '%([^ ]%{1,}%) :[0-9]' || continue
sargs=$cmd displ="$displ$dpy "
done
for dpy from 0 to 9 repeat
do
echo " :$dpy%c"
expr "$displ" :: ":$dpy " || sargs="$sargs :$dpy" break
done
echo
if expr "$sargs" :: '/[^ ]%{1,} :[0-9]'
then echo trying display :$dpy ...; sleep -m 1700
else sargs=''
fi
}
# /---------------------------------------------------
exec xinit $cargs -- $sargs |