summaryrefslogtreecommitdiffstats
path: root/source/x/x11/post-install/xdm/Xsession
blob: 6484b0965af229e9df27cf83fc333f04d55e7c99 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/sh
# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
#
#
# $XFree86: xc/programs/xdm/config/Xsession,v 1.2 1998/01/11 03:48:32 dawes Exp $
# Modified for Slackware-3.5, 28-Mar-98 volkerdi
# Extensively rewritten for Slackware 7.0, 03-Oct-1999 volkerdi
# Patched to give priority to $HOME/.xsession, 10-Oct-1999 volkerdi
# Merged changes into upstream (XFree86-4.0.2) version, 17-Feb-2001 volkerdi
# Fixes for $PATH (from Jim Diamond), GDM/KDM/XDM, 2003-02-07 volkerdi
# Use absolute paths until $PATH is set, 2006-01-11 (Al's 100th :-) volkerdi
# merged changes from # $Xorg: Xsession,v 1.4 2000/08/17 19:54:17 cpqbld Exp $, 2007-02-13 volkerdi

# redirect errors to a file in user's home directory if we can
errfile="$HOME/.xsession-errors"
if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null )
then
        exec > "$errfile" 2>&1
else

        mktemp=/usr/bin/mktemp
        for errfile in "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER"
        do
                if ef="$( umask 077 && $mktemp "$errfile.XXXXXX" 2> /dev/null)"
                then
                        exec > "$ef" 2>&1
                        mv "$ef" "$errfile" 2> /dev/null
                        break
                fi
        done
fi

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/lib/X11/xinit/.Xresources
sysmodmap=/usr/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -r $sysresources ]; then
	/usr/bin/xrdb -merge $sysresources
fi

if [ -r $sysmodmap ]; then
	/usr/bin/xmodmap $sysmodmap
fi

if [ -r $userresources ]; then
	/usr/bin/xrdb -merge $userresources
fi

if [ -r $usermodmap ]; then
	/usr/bin/xmodmap $usermodmap
fi

# Since xdm doesn't run a bash -login shell (or any other login shell)
# we should source these files to set up the user's environment.
profile=/etc/profile
userprofile=~/.profile

if [ -r $profile ]; then
        source $profile 1> /dev/null 2> /dev/null
fi
if [ -r $userprofile ]; then
        source $userprofile 1> /dev/null 2> /dev/null
fi

# Set the $PATH through the user's preferred shell.
case `basename "$SHELL"` in
bash|sh|ash)
	PATH="`( echo 'echo $PATH' | bash --login ) | tail -1`"
	;;
csh|tcsh)
	PATH="`( echo 'echo $PATH' | tcsh -l ) | tail -1`"
	;;
ksh)
	PATH="`( cat /etc/profile ; echo 'echo $PATH' ) | ksh | tail -1`"
	;;
zsh)
	PATH="`( echo 'echo $PATH' | zsh -l ) | tail -1`"
    	;;
*)
	# We don't know your shell, so we'll set up reasonable defaults.
     	if [ "`whoami`" = "root" ]; then
		PATH=$PATH:/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin
     	else
		PATH=$PATH:/usr/local/bin:/bin:/usr/bin
       	fi
     	;;
esac

# These files (if they exist) are used to set up the X related environment.  We used to
# exec .xsession at this location, but that can interfere with choosing a session type
# through XDM/KDM/GDM so it was moved to after a requested session is started.  Since
# that means that .xsession might never be run at all when using XDM/KDM/GDM, support
# for the xprofile was added to allow a way for the user to customize the X environment.
if [ -r /etc/xprofile ]; then
	source /etc/xprofile
fi
if [ -r ~/.xprofile ]; then
	source ~/.xprofile
fi

# Some people say that an .xsession file should always be given priority, even if a
# different window manager was requested in $1.  If you want that behavior, uncomment
# the lines below.  This is not recommended (nor, in general, is the use of an
# .xsession file as a default... it should be left for the advanced users).
#if [ -x $HOME/.xsession ]; then
#        exec $HOME/.xsession $@
#fi

# If a particular session type was requested in $1, start that session:
case "$1" in
failsafe)
	xsetroot -solid SteelBlue
	exec xterm -geometry 80x24-0-0
	;;
kde)
	exec startkde
	;;
gnome)
	exec gnome-session
	;;
openwin)
	exec olvwm
	;;
fluxbox)
	exec fluxbox
	;;
fvwm2)
	xsetroot -solid SteelBlue
	exec fvwm2
	;;
fvwm95)
	xsetroot -solid SteelBlue
	exec fvwm95
	;;
blackbox)
	exec blackbox
	;;
xfce)
	exec /etc/X11/xinit/xinitrc.xfce
	;;
windowmaker)
	exec /etc/X11/xinit/xinitrc.wmaker
	;;
afterstep)
	exec afterstep
	;;
enlightenment)
	exec enlightenment
	;;
twm)
	#xclock -geometry 50x50-1+1 &
	#xterm -geometry 80x50+494+51 &
	#xterm -geometry 80x20+494-0 &
	#xterm -geometry 80x66+0+0 -name login &
	xsetroot -solid SteelBlue
	exec twm
	;;
esac

# If we aren't running from XDM/KDM/GDM and no window manager was
# specified, then we'll run the user's $HOME/.xsession if it's
# executable.  This must be set up to run the user's window manager.
if [ -x $HOME/.xsession ]; then
        exec $HOME/.xsession $@
fi

# If the user doesn't have their own xsession and none was specified in
# $1, then run the system default session type:
if [ -r /etc/X11/xinit/xinitrc ]; then
	exec /etc/X11/xinit/xinitrc
fi

# If a $startup variable is set to define the window or session manager,
# then run that:
if [ -s "$startup" -a -x "$startup" ]; then
	exec "$startup"
else
	if [ -r "$resources" ]; then
		/usr/bin/xrdb -load "$resources"
	fi
	# Run xsm as a failsafe.
	exec xsm
fi

startup=$HOME/.xsession
resources=$HOME/.Xresources

if [ -s "$startup" ]; then
        if [ -x "$startup" ]; then
                exec "$startup"
        else
                exec /bin/sh "$startup"
        fi
else
        if [ -r "$resources" ]; then
                /usr/bin/xrdb -load "$resources"
        fi
        exec /usr/bin/xsm
fi