Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Stuff
Monday, November 19th, 2007 at 6:06:47pm UTC 

  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. userclientrc=$HOME/.xinitrc
  16. sysclientrc=/etc/X11/xinit/xinitrc
  17.  
  18.  
  19. userserverrc=$HOME/.xserverrc
  20. sysserverrc=/etc/X11/xinit/xserverrc
  21. defaultclient=xterm
  22. defaultserver=/usr/bin/X
  23. defaultclientargs=""
  24. defaultserverargs=""
  25. clientargs=""
  26. serverargs=""
  27.  
  28. if [ -f $userclientrc ]; then
  29.     defaultclientargs=$userclientrc
  30. elif [ -f $sysclientrc ]; then
  31.     defaultclientargs=$sysclientrc
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. fi
  39. if [ -f $userserverrc ]; then
  40.     defaultserverargs=$userserverrc
  41. elif [ -f $sysserverrc ]; then
  42.     defaultserverargs=$sysserverrc
  43. fi
  44.  
  45. whoseargs="client"
  46. while [ x"$1" != x ]; do
  47.     case "$1" in
  48.     # '' required to prevent cpp from treating "/*" as a C comment.
  49.     /''*|\./''*)
  50.  if [ "$whoseargs" = "client" ]; then
  51.      if [ x"$clientargs" = x ]; then
  52.   client="$1"
  53.      else
  54.   clientargs="$clientargs $1"
  55.      fi
  56.  else
  57.      if [ x"$serverargs" = x ]; then
  58.   server="$1"
  59.      else
  60.   serverargs="$serverargs $1"
  61.      fi
  62.  fi
  63.  ;;
  64.     --)
  65.  whoseargs="server"
  66.  ;;
  67.     *)
  68.  if [ "$whoseargs" = "client" ]; then
  69.      clientargs="$clientargs $1"
  70.  else
  71.      # display must be the FIRST server argument
  72.      if [ x"$serverargs" = x ] && \
  73.    expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
  74.   display="$1"
  75.      else
  76.   serverargs="$serverargs $1"
  77.      fi
  78.  fi
  79.  ;;
  80.     esac
  81.     shift
  82. done
  83.  
  84. # process client arguments
  85. if [ x"$client" = x ]; then
  86.     # if no client arguments either, use rc file instead
  87.     if [ x"$clientargs" = x ]; then
  88.  client="$defaultclientargs"
  89.     else
  90.  client=$defaultclient
  91.     fi
  92. fi
  93.  
  94. # process server arguments
  95. if [ x"$server" = x ]; then
  96.     # if no server arguments or display either, use rc file instead
  97.     if [ x"$serverargs" = x -a x"$display" = x ]; then
  98.  server="$defaultserverargs"
  99.     else
  100.  server=$defaultserver
  101.     fi
  102. fi
  103.  
  104. if [ x"$XAUTHORITY" = x ]; then
  105.     XAUTHORITY=$HOME/.Xauthority
  106.     export XAUTHORITY
  107. fi
  108.  
  109. removelist=
  110.  
  111.  
  112. # set up default Xauth info for this machine
  113.  
  114. # check for GNU hostname
  115. if hostname --version > /dev/null 2>&1; then
  116.        if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
  117.   hostname=`hostname -f`
  118.        fi
  119. fi
  120.  
  121. if [ -z "$hostname" ]; then
  122.  hostname=`hostname`
  123. fi
  124.  
  125. authdisplay=${display:-:0}
  126. mcookie=`/usr/bin/mcookie`
  127. dummy=0
  128.  
  129. # create a file with auth information for the server. ':0' is a dummy.
  130. xserverauthfile=$HOME/.serverauth.$$
  131. xauth -q -f $xserverauthfile << EOF
  132. add :$dummy . $mcookie
  133. EOF
  134. serverargs=${serverargs}" -auth "${xserverauthfile}
  135.  
  136. # now add the same credentials to the client authority file
  137. # if '$displayname' already exists do not overwrite it as another
  138. # server man need it. Add them to the '$xserverauthfile' instead.
  139. for displayname in $authdisplay $hostname$authdisplay; do
  140.      authcookie=`xauth list "$displayname" \
  141.        | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
  142.     if [ "z${authcookie}" = "z" ] ; then
  143.         xauth -q << EOF
  144. add $displayname . $mcookie
  145. EOF
  146.  removelist="$displayname $removelist"
  147.     else
  148.         dummy=$(($dummy+1));
  149.         xauth -q -f $xserverauthfile << EOF
  150. add :$dummy . $authcookie
  151. EOF
  152.     fi
  153. done
  154. xinit $client $clientargs -- $server $display $serverargs
  155.  
  156.  
  157. if [ x"$removelist" != x ]; then
  158.     xauth remove $removelist
  159. fi
  160. if [ x"$xserverauthfile" != x ]; then
  161.     rm -f $xserverauthfile
  162. fi
  163.  
  164.  
  165.  
  166.  
  167.  
  168. if command -v deallocvt > /dev/null 2>&1; then
  169.     deallocvt
  170. fi

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right worth-right