Xsession 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #!/bin/sh
  2. #
  3. # $Header: /var/cvsroot/gentoo-x86/x11-misc/slim/files/Xsession,v 1.1 2010/09/20 15:22:38 darkside Exp $
  4. #
  5. # SLiM Xsession script
  6. #
  7. # This script is a wrapper that handles selection of a session from
  8. # /etc/X11/Sessions/ as necessary. It doesn't handle actual session setup.
  9. #
  10. # The script takes a session name as the first argument. If no argument is
  11. # given, or if the argument does not match an available session script:
  12. # - Run ~/.xsession and if that's not available,
  13. # - Run the appropriate Xclients startup (see the code below)
  14. #
  15. # (Note that other arguments could also follow, but only the command one is
  16. # right now relevant and supported)
  17. #
  18. # The output is redirected to /var/log/slim.log.
  19. #
  20. # By default this is run in a login shell, see /etc/slim.conf for details.
  21. command="$@"
  22. # this will go into the slim.log along with all other echo's
  23. # good for debugging where things went wrong
  24. echo "$0: Beginning session setup..."
  25. # Read /etc/xprofile and .xprofile for X specific setup
  26. test -f /etc/xprofile && . /etc/xprofile
  27. test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
  28. # userresources and sysresources and all these other vars are
  29. # unneeded here as by default the session script we're handing
  30. # off to will take care of it.
  31. # wrap possible arguments to determine whether to treat special or not
  32. if [ "x$command" = "xcustom" ] || [ "x$command" = "xCustom" ] || \
  33. [ "x$command" = "xdefault" ] || [ "x$command" = "xDefault" ]; then
  34. command="Xsession"
  35. fi
  36. if [ "x$command" = "x" ]; then
  37. # no default specified, check if Xsession will complete
  38. # and if not then assign XSESSION to command
  39. if [ -x "$HOME/.xsession" ] || [ -x "$HOME/.Xclients" ] || \
  40. [ -x /etc/X11/xinit/Xclients ] || [ -x /etc/X11/Xclients ]; then
  41. command="Xsession"
  42. else
  43. command=$XSESSION
  44. fi
  45. fi
  46. # ripped directly from /etc/X11/chooser.sh
  47. defaultDesktopSession=`sed -e '/^SESSION/!d' -e 's/\(.*\)=\(.*\)/\2/' /etc/default/desktop`
  48. sessionscript=""
  49. for x in /usr/share/xsessions/* ; do
  50. if [ "$defaultDesktopSession" == `basename $x .desktop` ]; then
  51. sessionscript=`sed -e '/^Exec/!d' -e 's/\(.*\)=\(.*\)/\2/' $x`
  52. break
  53. fi
  54. done
  55. if [ -n "$sessionscript" ]; then
  56. if [ -f ${sessionscript} ]; then
  57. if [ -x ${sessionscript} ]; then
  58. exec "${sessionscript}"
  59. else
  60. exec /bin/sh "${sessionscript}"
  61. fi
  62. fi
  63. echo "Unable to execute session script ${sessionscript}"
  64. exit 1
  65. fi
  66. # Launch a default session
  67. # This was mostly ripped from GDM's Xsession script
  68. echo "Could not find appropriate session script, exec'ing xterm"
  69. userresources="$HOME/.Xresources"
  70. usermodmap="$HOME/.Xmodmap"
  71. userxkbmap="$HOME/.Xkbmap"
  72. sysresources=/etc/X11/Xresources
  73. sysmodmap=/etc/X11/Xmodmap
  74. sysxkbmap=/etc/X11/Xkbmap
  75. rh6sysresources=/etc/X11/xinit/Xresources
  76. rh6sysmodmap=/etc/X11/xinit/Xmodmap
  77. # merge in defaults
  78. if [ -f "$rh6sysresources" ]; then
  79. xrdb -merge "$rh6sysresources"
  80. fi
  81. if [ -f "$sysresources" ]; then
  82. xrdb -merge "$sysresources"
  83. fi
  84. if [ -f "$userresources" ]; then
  85. xrdb -merge "$userresources"
  86. fi
  87. # merge in keymaps
  88. if [ -f "$sysxkbmap" ]; then
  89. setxkbmap `cat "$sysxkbmap"`
  90. XKB_IN_USE=yes
  91. fi
  92. if [ -f "$userxkbmap" ]; then
  93. setxkbmap `cat "$userxkbmap"`
  94. XKB_IN_USE=yes
  95. fi
  96. #
  97. # Eeek, this seems like too much magic here
  98. #
  99. if [ -z "$XKB_IN_USE" -a ! -L /etc/X11/X ]; then
  100. if grep '^exec.*/Xsun' /etc/X11/X > /dev/null 2>&1 && [ -f /etc/X11/XF86Config ]; then
  101. xkbsymbols=`sed -n -e 's/^[ ]*XkbSymbols[ ]*"\(.*\)".*$/\1/p' /etc/X11/XF86Config`
  102. if [ -n "$xkbsymbols" ]; then
  103. setxkbmap -symbols "$xkbsymbols"
  104. XKB_IN_USE=yes
  105. fi
  106. fi
  107. fi
  108. # xkb and xmodmap don't play nice together
  109. if [ -z "$XKB_IN_USE" ]; then
  110. if [ -f "$rh6sysmodmap" ]; then
  111. xmodmap "$rh6sysmodmap"
  112. fi
  113. if [ -f "$sysmodmap" ]; then
  114. xmodmap "$sysmodmap"
  115. fi
  116. if [ -f "$usermodmap" ]; then
  117. xmodmap "$usermodmap"
  118. fi
  119. fi
  120. unset XKB_IN_USE
  121. # run all system xinitrc shell scripts.
  122. if [ -d /etc/X11/xinit/xinitrc.d ]; then
  123. for i in /etc/X11/xinit/xinitrc.d/* ; do
  124. if [ -x "$i" ]; then
  125. . "$i"
  126. fi
  127. done
  128. fi
  129. exec xterm -geometry 80x24+0+0