Advertisement
Guest User

startx

a guest
Sep 30th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.98 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #
  4. # This is just a sample implementation of a slightly less primitive
  5. # interface than xinit. It looks for user .xinitrc and .xserverrc
  6. # files, then system xinitrc and xserverrc files, else lets xinit choose
  7. # its default. The system xinitrc should probably do things like check
  8. # for .Xresources files and merge them in, start up a window manager,
  9. # and pop a clock and several xterms.
  10. #
  11. # Site administrators are STRONGLY urged to write nicer versions.
  12. #
  13.  
  14. unset DBUS_SESSION_BUS_ADDRESS
  15. unset SESSION_MANAGER
  16. userclientrc=$HOME/.xinitrc
  17. sysclientrc=/etc/X11/xinit/xinitrc
  18.  
  19. userserverrc=$HOME/.xserverrc
  20. sysserverrc=/etc/X11/xinit/xserverrc
  21. defaultclient=xterm
  22. defaultserver=/usr/bin/X
  23. defaultclientargs=""
  24. defaultserverargs=""
  25. defaultdisplay=":0"
  26. clientargs=""
  27. serverargs=""
  28. vtarg=""
  29. enable_xauth=1
  30.  
  31.  
  32. # Automatically determine an unused $DISPLAY
  33. d=0
  34. while true ; do
  35.     [ -e /tmp/.X$d-lock ] || break
  36.     d=$(($d + 1))
  37. done
  38. defaultdisplay=":$d"
  39. unset d
  40.  
  41. whoseargs="client"
  42. while [ x"$1" != x ]; do
  43.     case "$1" in
  44.     # '' required to prevent cpp from treating "/*" as a C comment.
  45.     /''*|\./''*)
  46.  if [ "$whoseargs" = "client" ]; then
  47.      if [ x"$client" = x ] && [ x"$clientargs" = x ]; then
  48.   client="$1"
  49.      else
  50.   clientargs="$clientargs $1"
  51.      fi
  52.  else
  53.      if [ x"$server" = x ] && [ x"$serverargs" = x ]; then
  54.   server="$1"
  55.      else
  56.   serverargs="$serverargs $1"
  57.      fi
  58.  fi
  59.  ;;
  60.     --)
  61.  whoseargs="server"
  62.  ;;
  63.     *)
  64.  if [ "$whoseargs" = "client" ]; then
  65.      clientargs="$clientargs $1"
  66.  else
  67.      # display must be the FIRST server argument
  68.      if [ x"$serverargs" = x ] && \
  69.    expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
  70.   display="$1"
  71.      else
  72.   serverargs="$serverargs $1"
  73.      fi
  74.  fi
  75.  ;;
  76.     esac
  77.     shift
  78. done
  79.  
  80. # process client arguments
  81. if [ x"$client" = x ]; then
  82.     client=$defaultclient
  83.  
  84.     # For compatibility reasons, only use startxrc if there were no client command line arguments
  85.     if [ x"$clientargs" = x ]; then
  86.         if [ -f "$userclientrc" ]; then
  87.             client=$userclientrc
  88.         elif [ -f "$sysclientrc" ]; then
  89.             client=$sysclientrc
  90.         fi
  91.     fi
  92. fi
  93.  
  94. # if no client arguments, use defaults
  95. if [ x"$clientargs" = x ]; then
  96.     clientargs=$defaultclientargs
  97. fi
  98.  
  99. # process server arguments
  100. if [ x"$server" = x ]; then
  101.     server=$defaultserver
  102.  
  103.  
  104.     # When starting the defaultserver start X on the current tty to avoid
  105.     # the startx session being seen as inactive:
  106.     # "https://bugzilla.redhat.com/show_bug.cgi?id=806491"
  107.     tty=$(tty)
  108.     if expr match "$tty" '^/dev/tty[0-9]\+$' > /dev/null; then
  109.         tty_num=$(echo "$tty" | grep -oE '[0-9]+$')
  110.         vtarg="vt$tty_num"
  111.     fi
  112.  
  113.  
  114.     # For compatibility reasons, only use xserverrc if there were no server command line arguments
  115.     if [ x"$serverargs" = x -a x"$display" = x ]; then
  116.  if [ -f "$userserverrc" ]; then
  117.      server=$userserverrc
  118.  elif [ -f "$sysserverrc" ]; then
  119.      server=$sysserverrc
  120.  fi
  121.     fi
  122. fi
  123.  
  124. # if no server arguments, use defaults
  125. if [ x"$serverargs" = x ]; then
  126.     serverargs=$defaultserverargs
  127. fi
  128.  
  129. # if no vt is specified add vtarg (which may be empty)
  130. have_vtarg="no"
  131. for i in $serverargs; do
  132.     if expr match "$i" '^vt[0-9]\+$' > /dev/null; then
  133.         have_vtarg="yes"
  134.     fi
  135. done
  136. if [ "$have_vtarg" = "no" ]; then
  137.     serverargs="$serverargs $vtarg"
  138. fi
  139.  
  140. # if no display, use default
  141. if [ x"$display" = x ]; then
  142.     display=$defaultdisplay
  143. fi
  144.  
  145. #~ if [ x"$enable_xauth" = x1 ] ; then
  146.     #~ if [ x"$XAUTHORITY" = x ]; then
  147.         #~ XAUTHORITY=$HOME/.Xauthority
  148.         #~ export XAUTHORITY
  149.     #~ fi
  150.  
  151.     #~ removelist=
  152.  
  153.     #~ # set up default Xauth info for this machine
  154.     #~ case `uname` in
  155.     #~ Linux*)
  156.         #~ if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
  157.             #~ hostname=`hostname -f`
  158.         #~ else
  159.             #~ hostname=`hostname`
  160.         #~ fi
  161.         #~ ;;
  162.     #~ *)
  163.         #~ hostname=`hostname`
  164.         #~ ;;
  165.     #~ esac
  166.  
  167.     #~ authdisplay=${display:-:0}
  168.  
  169.     #~ mcookie=`/usr/bin/mcookie`
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.     #~ if test x"$mcookie" = x; then
  178.         #~ echo "Couldn't create cookie"
  179.         #~ exit 1
  180.     #~ fi
  181.     #~ dummy=0
  182.  
  183.     #~ # create a file with auth information for the server. ':0' is a dummy.
  184.     #~ xserverauthfile=`mktemp -p /tmp serverauth.XXXXXXXXXX`
  185.     #~ trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP KILL BUS TERM
  186.     #~ xauth -q -f "$xserverauthfile" << EOF
  187. #~ add :$dummy . $mcookie
  188. #~ EOF
  189.  
  190.  
  191.  
  192.  
  193.     #~ serverargs=${serverargs}" -auth "${xserverauthfile}
  194.  
  195.  
  196.     #~ # now add the same credentials to the client authority file
  197.     #~ # if '$displayname' already exists do not overwrite it as another
  198.     #~ # server man need it. Add them to the '$xserverauthfile' instead.
  199.     #~ for displayname in $authdisplay $hostname/unix$authdisplay; do
  200.         #~ authcookie=`xauth list "$displayname" \
  201.         #~ | sed -n "s/.*$hostname\/unix$authdisplay[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
  202.         #~ if [ "z${authcookie}" = "z" ] ; then
  203.             #~ xauth -q << EOF
  204. #~ add $displayname . $mcookie
  205. #~ EOF
  206.         #~ removelist="$displayname $removelist"
  207.         #~ else
  208.             #~ dummy=$(($dummy+1));
  209.             #~ xauth -q -f "$xserverauthfile" << EOF
  210. #~ add :$dummy . $authcookie
  211. #~ EOF
  212.         #~ fi
  213.     #~ done
  214. #~ fi
  215.  
  216.  
  217.  
  218.  
  219. #~ xinit "$client" $clientargs -- "$server" $display $serverargs
  220.  
  221. echo "xinit debug output"
  222. echo "------------------"
  223. echo "client: $client"
  224. echo "clientargs: $clientargs"
  225. echo "--"
  226. echo "server: $server"
  227. echo "display: $display"
  228. echo "serverargs: $serverargs"
  229.  
  230.  
  231. #~ retval=$?
  232.  
  233. #~ if [ x"$enable_xauth" = x1 ] ; then
  234.     #~ if [ x"$removelist" != x ]; then
  235.         #~ xauth remove $removelist
  236.     #~ fi
  237.     #~ if [ x"$xserverauthfile" != x ]; then
  238.         #~ rm -f "$xserverauthfile"
  239.     #~ fi
  240. #~ fi
  241.  
  242.  
  243.  
  244.  
  245.  
  246. #~ if command -v deallocvt > /dev/null 2>&1; then
  247.     #~ deallocvt
  248. #~ fi
  249. #~ exit $retval
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement