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