Xsession 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
  3. # copyrighted material is made available to anyone wishing to use, modify,
  4. # copy, or redistribute it subject to the terms and conditions of the
  5. # GNU General Public License version 2.
  6. #
  7. # You should have received a copy of the GNU General Public License
  8. # along with this program; if not, write to the Free Software
  9. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  10. # redirect errors to a file in user's home directory if we can
  11. if [ -z "$GDMSESSION" ]; then
  12. # GDM redirect output itself in a smarter fashion
  13. errfile="$HOME/.xsession-errors"
  14. if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null ); then
  15. chmod 600 "$errfile"
  16. [ -x /sbin/restorecon ] && /sbin/restorecon $errfile
  17. exec > "$errfile" 2>&1
  18. else
  19. errfile=$(mktemp -q /tmp/xses-$USER.XXXXXX)
  20. if [ $? -eq 0 ]; then
  21. exec > "$errfile" 2>&1
  22. fi
  23. fi
  24. fi
  25. SWITCHDESKPATH=/usr/share/switchdesk
  26. # Mandatorily source xinitrc-common, which is common code shared between the
  27. # Xsession and xinitrc scripts which has been factored out to avoid duplication
  28. . /etc/X11/xinit/xinitrc-common
  29. # This Xsession.d implementation, is intended to obsolte and replace the
  30. # various mechanisms present in the 'case' statement which follows, and to
  31. # eventually be able to easily remove all hard coded window manager specific
  32. # content from this script. See bug #142260 for additional explanation and
  33. # details. All window manager rpm packages and desktop environment
  34. # packages should be modified to provide the Xsession.d/Xsession.$wm scripts
  35. # to start themselves up. In the future, the legacy switchdesk mechanisms
  36. # and hard coded window managers and desktop environments will be removed from
  37. # this script.
  38. XCLIENTS_D=/etc/X11/xinit/Xclients.d
  39. if [ "$#" -eq 1 ] && [ -x "$XCLIENTS_D/Xclients.$1.sh" ]; then
  40. exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT $XCLIENTS_D/Xclients.$1.sh"
  41. else
  42. # now, we see if xdm/gdm/kdm has asked for a specific environment
  43. case $# in
  44. 1)
  45. if [ -x "$SWITCHDESKPATH/Xclients.$1" ]; then
  46. exec -l $SHELL -c "$SWITCHDESKPATH/Xclients.$1";
  47. fi;
  48. case "$1" in
  49. failsafe)
  50. exec -l $SHELL -c "xterm -geometry 80x24-0-0"
  51. ;;
  52. gnome|gnome-session)
  53. # lack of SSH_AGENT is intentional, see #441123. though
  54. # the whole thing should really happen in xinitrc.d anyway.
  55. exec -l $SHELL -c gnome-session
  56. exec /bin/sh -c "exec -l $SHELL -c \"gnome-session\""
  57. ;;
  58. kde|kde1|kde2)
  59. exec $CK_XINIT_SESSION $SSH_AGENT /bin/sh -c "exec -l $SHELL -c \"startkde\""
  60. ;;
  61. twm)
  62. # fall back to twm
  63. exec $CK_XINIT_SESSION $SSH_AGENT /bin/sh -c "exec -l $SHELL -c \"twm\""
  64. ;;
  65. *)
  66. # GDM provies either a command line as the first argument or
  67. # provides 'failsafe', 'default' or 'custom'. KDM will do the
  68. # same at some point
  69. if [ "$1" != "default" -a "$1" != "custom" ]; then
  70. exec $CK_XINIT_SESSION $SSH_AGENT /bin/sh -c "exec -l $SHELL -c \"$1\""
  71. fi
  72. ;;
  73. esac
  74. esac
  75. fi
  76. # otherwise, take default action
  77. if [ -x "$HOME/.xsession" ]; then
  78. exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT $HOME/.xsession"
  79. elif [ -x "$HOME/.Xclients" ]; then
  80. exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients"
  81. elif [ -x /etc/X11/xinit/Xclients ]; then
  82. exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients"
  83. else
  84. # should never get here; failsafe fallback
  85. exec -l $SHELL -c "xsm"
  86. fi