home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 November - Disc 1 / PCNET_CD_2006_11_1.iso / linux / gparted-livecd-0.3.1-1.iso / gparted / usr / X11R6 / bin / startx < prev    next >
Encoding:
Text File  |  2006-05-02  |  3.9 KB  |  192 lines

  1. #!/bin/sh
  2.  
  3. # $Xorg: startx.cpp,v 1.3 2000/08/17 19:54:29 cpqbld Exp $
  4. #
  5. # This is just a sample implementation of a slightly less primitive
  6. # interface than xinit.  It looks for user .xinitrc and .xserverrc
  7. # files, then system xinitrc and xserverrc files, else lets xinit choose
  8. # its default.  The system xinitrc should probably do things like check
  9. # for .Xresources files and merge them in, startup up a window manager,
  10. # and pop a clock and serveral xterms.
  11. #
  12. # Site administrators are STRONGLY urged to write nicer versions.
  13. #
  14. # $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $
  15.  
  16. userclientrc=$HOME/.xinitrc
  17. sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc
  18.  
  19.  
  20. userserverrc=$HOME/.xserverrc
  21. sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc
  22. defaultclient=/usr/X11R6/bin/xterm
  23. defaultserver=/usr/X11R6/bin/X
  24. defaultclientargs=""
  25. defaultserverargs=""
  26. clientargs=""
  27. serverargs=""
  28.  
  29. if [ -f $userclientrc ]; then
  30.     defaultclientargs=$userclientrc
  31. elif [ -f $sysclientrc ]; then
  32.     defaultclientargs=$sysclientrc
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. fi
  40.  
  41.  
  42. if [ -f $userserverrc ]; then
  43.     defaultserverargs=$userserverrc
  44. elif [ -f $sysserverrc ]; then
  45.     defaultserverargs=$sysserverrc
  46. fi
  47.  
  48. whoseargs="client"
  49. while [ x"$1" != x ]; do
  50.     case "$1" in
  51.     # '' required to prevent cpp from treating "/*" as a C comment.
  52.     /''*|\./''*)
  53.     if [ "$whoseargs" = "client" ]; then
  54.         if [ x"$clientargs" = x ]; then
  55.         client="$1"
  56.         else
  57.         clientargs="$clientargs $1"
  58.         fi
  59.     else
  60.         if [ x"$serverargs" = x ]; then
  61.         server="$1"
  62.         else
  63.         serverargs="$serverargs $1"
  64.         fi
  65.     fi
  66.     ;;
  67.     --)
  68.     whoseargs="server"
  69.     ;;
  70.     *)
  71.     if [ "$whoseargs" = "client" ]; then
  72.         clientargs="$clientargs $1"
  73.     else
  74.         # display must be the FIRST server argument
  75.         if [ x"$serverargs" = x ] && \
  76.          expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
  77.         display="$1"
  78.         else
  79.         serverargs="$serverargs $1"
  80.         fi
  81.     fi
  82.     ;;
  83.     esac
  84.     shift
  85. done
  86.  
  87. # process client arguments
  88. if [ x"$client" = x ]; then
  89.     # if no client arguments either, use rc file instead
  90.     if [ x"$clientargs" = x ]; then
  91.     client="$defaultclientargs"
  92.     else
  93.     client=$defaultclient
  94.     fi
  95. fi
  96.  
  97. # process server arguments
  98. if [ x"$server" = x ]; then
  99.     # if no server arguments or display either, use rc file instead
  100.     if [ x"$serverargs" = x -a x"$display" = x ]; then
  101.     server="$defaultserverargs"
  102.     else
  103.     server=$defaultserver
  104.     fi
  105. fi
  106.  
  107. if [ x"$XAUTHORITY" = x ]; then
  108.     XAUTHORITY=$HOME/.Xauthority
  109.     export XAUTHORITY
  110. fi
  111.  
  112. removelist=
  113.  
  114.  
  115. # set up default Xauth info for this machine
  116. case `uname` in
  117. Linux*)
  118.     if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
  119.         hostname=`hostname -f`
  120.     else
  121.         hostname=`hostname`
  122.     fi
  123.     ;;
  124. *)
  125.     hostname=`hostname`
  126.     ;;
  127. esac
  128.  
  129. authdisplay=${display:-:0}
  130. mcookie=`mcookie`
  131. dummy=0
  132.  
  133. # create a file with auth information for the server. ':0' is a dummy.
  134. xserverauthfile=$HOME/.serverauth.$$
  135. xauth -q -f $xserverauthfile << EOF
  136. add :$dummy . $mcookie
  137. EOF
  138. serverargs=${serverargs}" -auth "${xserverauthfile}
  139.  
  140. # now add the same credentials to the client authority file
  141. # if '$displayname' already exists don't overwrite it as another
  142. # server man need it. Add them to the '$xserverauthfile' instead.
  143. for displayname in $authdisplay $hostname$authdisplay; do
  144.      authcookie=`/usr/X11R6/bin/xauth list "$displayname" \
  145.        | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
  146.     if [ "z${authcookie}" = "z" ] ; then
  147.         /usr/X11R6/bin/xauth -q << EOF 
  148. add $displayname . $mcookie
  149. EOF
  150.     removelist="$displayname $removelist"
  151.     else
  152.         dummy=$((dummy+1));
  153.         /usr/X11R6/bin/xauth -q -f $xserverauthfile << EOF
  154. add :$dummy . $authcookie
  155. EOF
  156.     fi
  157. done
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. /usr/X11R6/bin/xinit $client $clientargs -- $server $display $serverargs
  169.  
  170.  
  171. if [ x"$removelist" != x ]; then
  172.     /usr/X11R6/bin/xauth remove $removelist
  173. fi
  174. if [ x"$xserverauthfile" != x ]; then
  175.     rm -f $xserverauthfile
  176. fi
  177.     
  178.  
  179.  
  180.  
  181.  
  182. if command -v deallocvt > /dev/null 2>&1; then
  183.     deallocvt
  184. fi
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.