3
# This is SORT OF LIKE an X session, but not quite. You get a command as the
4
# first argument (it could be multiple words, so run it with "eval"). As a
5
# special case, the command can be:
6
# default - Run the appropriate Xclients startup (see the code below)
7
# custom - Run ~/.xsession and if that's not available run 'default'
9
# (Note that other arguments could also follow, but only the command one is
10
# right now relevant and supported)
12
# The output is ALREADY redirected to .xsession-errors in GDM. This way
13
# .xsession-errors actually gets more output such as if the PreSession script
14
# is failing. This also prevents DoS attacks if some app in the users session
15
# can be prodded to dump lots of stuff on the stdout/stderr. We wish to be
16
# robust don't we? In case you wish to use an existing script for other DM's,
17
# you can just not redirect when GDMSESSION is set. GDMSESSION will always
20
# Also note that this is not run as a login shell, this is just executed.
21
# This is why we source the profile files below.
24
# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
28
# this will go into the .xsession-errors along with all other echo's
29
# good for debugging where things went wrong
30
echo "$0: Beginning session setup..."
32
# First read /etc/profile and .profile
33
test -f /etc/profile && . /etc/profile
34
test -f "$HOME/.profile" && . "$HOME/.profile"
35
# Second read /etc/xprofile and .xprofile for X specific setup
36
test -f /etc/xprofile && . /etc/xprofile
37
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
40
if [ -x "@libexecdir@/gdmtranslate" ] ; then
41
gdmtranslate="@libexecdir@/gdmtranslate"
46
# Note that this should only go to zenity dialogs which always expect utf8
48
if [ "x$gdmtranslate" != "x" ] ; then
49
"$gdmtranslate" --utf8 "$1"
63
if test -x "$dir/$COMMAND" ; then
64
if test "x$OUTPUT" = "x" ; then
65
OUTPUT="$dir/$COMMAND"
73
zenity=`gdmwhich zenity`
75
# Note: ~/.xsession-errors is now done in the daemon so that it
76
# works for ALL sessions (except ones named 'Failsafe')
78
# clean up after xbanner
79
freetemp=`gdmwhich freetemp`
80
if [ -n "$freetemp" ] ; then
84
userresources="$HOME/.Xresources"
85
usermodmap="$HOME/.Xmodmap"
86
userxkbmap="$HOME/.Xkbmap"
88
sysresources=/etc/X11/Xresources
89
sysmodmap=/etc/X11/Xmodmap
90
sysxkbmap=/etc/X11/Xkbmap
92
rh6sysresources=/etc/X11/xinit/Xresources
93
rh6sysmodmap=/etc/X11/xinit/Xmodmap
96
if [ -f "$rh6sysresources" ]; then
97
xrdb -nocpp -merge "$rh6sysresources"
100
if [ -f "$sysresources" ]; then
101
xrdb -nocpp -merge "$sysresources"
104
if [ -f "$userresources" ]; then
105
xrdb -nocpp -merge "$userresources"
109
if [ -f "$sysxkbmap" ]; then
110
setxkbmap `cat "$sysxkbmap"`
114
if [ -f "$userxkbmap" ]; then
115
setxkbmap `cat "$userxkbmap"`
120
# Eeek, this seems like too much magic here
122
if [ -z "$XKB_IN_USE" -a ! -L /etc/X11/X ]; then
123
if grep '^exec.*/Xsun' /etc/X11/X > /dev/null 2>&1 && [ -f /etc/X11/XF86Config ]; then
124
xkbsymbols=`sed -n -e 's/^[ ]*XkbSymbols[ ]*"\(.*\)".*$/\1/p' /etc/X11/XF86Config`
125
if [ -n "$xkbsymbols" ]; then
126
setxkbmap -symbols "$xkbsymbols"
132
# xkb and xmodmap don't play nice together
133
if [ -z "$XKB_IN_USE" ]; then
134
if [ -f "$rh6sysmodmap" ]; then
135
xmodmap "$rh6sysmodmap"
138
if [ -f "$sysmodmap" ]; then
142
if [ -f "$usermodmap" ]; then
143
xmodmap "$usermodmap"
149
# Normalize languages, some places/distros screw us up in /etc/profile,
150
# so in case the user did select a language
151
if [ -n "$GDM_LANG" ]; then
155
if [ -n "$LC_ALL" ]; then
156
if [ "$LC_ALL" != "$LANG" ]; then
163
if [ -n "$LANGUAGE" ]; then
164
if [ "$LANGUAGE" != "$LANG" ]; then
171
if [ -n "$LINGUAS" ]; then
172
if [ "$LINGUAS" != "$LANG" ]; then
180
# run all system xinitrc shell scripts.
181
if [ -d /etc/X11/xinit/xinitrc.d ]; then
182
for i in /etc/X11/xinit/xinitrc.d/* ; do
183
if [ -x "$i" -a ! -d "$i" ]; then
189
if [ "x$command" = "xcustom" ] ; then
190
if [ -x "$HOME/.xsession" ]; then
191
command="$HOME/.xsession"
193
echo "$0: Cannot find ~/.xsession will try the default session"
198
if [ "x$command" = "xdefault" ] ; then
199
if [ -x "$HOME/.Xclients" ]; then
200
command="$HOME/.Xclients"
201
elif [ -x /etc/X11/xinit/Xclients ]; then
202
command="/etc/X11/xinit/Xclients"
203
elif [ -x /etc/X11/Xclients ]; then
204
command="/etc/X11/Xclients"
206
if [ -n "$zenity" ] ; then
207
disptext=`gettextfunc "System has no Xclients file, so starting a failsafe xterm session. Windows will have focus only if the mouse pointer is above them. To get out of this mode type 'exit' in the window."`
208
"$zenity" --info --text "$disptext"
210
echo "$0: Cannot find Xclients"
212
exec xterm -geometry 80x24+0+0
216
# add ssh-agent if found
217
sshagent="`gdmwhich ssh-agent`"
218
if [ -n "$sshagent" ] && [ -x "$sshagent" ] && [ -z "$SSH_AUTH_SOCK" ]; then
219
command="$sshagent -- $command"
220
elif [ -z "$sshagent" ] ; then
221
echo "$0: ssh-agent not found!"
224
echo "$0: Setup done, will execute: $command"
228
echo "$0: Executing $command failed, will run xterm"
230
if [ -n "$zenity" ] ; then
231
disptext=`gettextfunc "Failed to start the session, so starting a failsafe xterm session. Windows will have focus only if the mouse pointer is above them. To get out of this mode type 'exit' in the window."`
232
"$zenity" --info --text "$disptext"
235
exec xterm -geometry 80x24+0+0