source: proiecte/PPPP/gdm/data/Xsession.in @ 134

Last change on this file since 134 was 134, checked in by (none), 14 years ago

gdm sources with the modifications for webcam

  • Property svn:executable set to *
File size: 6.0 KB
Line 
1#!@XSESSION_SHELL@
2#
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'
8#
9# (Note that other arguments could also follow, but only the command one is
10# right now relevant and supported)
11#
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
18# be set from gdm.
19#
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.
22#
23# based on:
24# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
25
26command="$@"
27
28# this will go into the .xsession-errors along with all other echo's
29# good for debugging where things went wrong
30echo "$0: Beginning session setup..."
31
32# First read /etc/profile and .profile
33test -f /etc/profile && . /etc/profile
34test -f "$HOME/.profile" && . "$HOME/.profile"
35# Second read /etc/xprofile and .xprofile for X specific setup
36test -f /etc/xprofile && . /etc/xprofile
37test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
38
39# Translation stuff
40if [ -x "@libexecdir@/gdmtranslate" ] ; then
41  gdmtranslate="@libexecdir@/gdmtranslate"
42else
43  gdmtranslate=
44fi
45
46# Note that this should only go to zenity dialogs which always expect utf8
47gettextfunc () {
48  if [ "x$gdmtranslate" != "x" ] ; then
49    "$gdmtranslate" --utf8 "$1"
50  else
51    echo "$1"
52  fi
53}
54
55OLD_IFS=$IFS
56
57gdmwhich () {
58  COMMAND="$1"
59  OUTPUT=
60  IFS=:
61  for dir in $PATH
62  do
63    if test -x "$dir/$COMMAND" ; then
64      if test "x$OUTPUT" = "x" ; then
65        OUTPUT="$dir/$COMMAND"
66      fi
67    fi
68  done
69  IFS=$OLD_IFS
70  echo "$OUTPUT"
71}
72
73zenity=`gdmwhich zenity`
74
75# Note: ~/.xsession-errors is now done in the daemon so that it
76# works for ALL sessions (except ones named 'Failsafe')
77
78# clean up after xbanner
79freetemp=`gdmwhich freetemp`
80if [ -n "$freetemp" ] ; then
81        "$freetemp"
82fi
83
84userresources="$HOME/.Xresources"
85usermodmap="$HOME/.Xmodmap"
86userxkbmap="$HOME/.Xkbmap"
87
88sysresources=/etc/X11/Xresources
89sysmodmap=/etc/X11/Xmodmap
90sysxkbmap=/etc/X11/Xkbmap
91
92rh6sysresources=/etc/X11/xinit/Xresources
93rh6sysmodmap=/etc/X11/xinit/Xmodmap
94
95# merge in defaults
96if [ -f "$rh6sysresources" ]; then
97    xrdb -nocpp -merge "$rh6sysresources"
98fi
99
100if [ -f "$sysresources" ]; then
101    xrdb -nocpp -merge "$sysresources"
102fi
103
104if [ -f "$userresources" ]; then
105    xrdb -nocpp -merge "$userresources"
106fi
107
108# merge in keymaps
109if [ -f "$sysxkbmap" ]; then
110    setxkbmap `cat "$sysxkbmap"`
111    XKB_IN_USE=yes
112fi
113
114if [ -f "$userxkbmap" ]; then
115    setxkbmap `cat "$userxkbmap"`
116    XKB_IN_USE=yes
117fi
118
119#
120# Eeek, this seems like too much magic here
121#
122if [ -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"
127           XKB_IN_USE=yes
128       fi
129    fi
130fi
131
132# xkb and xmodmap don't play nice together
133if [ -z "$XKB_IN_USE" ]; then
134    if [ -f "$rh6sysmodmap" ]; then
135       xmodmap "$rh6sysmodmap"
136    fi
137
138    if [ -f "$sysmodmap" ]; then
139       xmodmap "$sysmodmap"
140    fi
141
142    if [ -f "$usermodmap" ]; then
143       xmodmap "$usermodmap"
144    fi
145fi
146
147unset XKB_IN_USE
148
149# Normalize languages, some places/distros screw us up in /etc/profile,
150# so in case the user did select a language
151if [ -n "$GDM_LANG" ]; then
152  LANG="$GDM_LANG"
153  export LANG
154
155  if [ -n "$LC_ALL" ]; then
156    if [ "$LC_ALL" != "$LANG" ]; then
157      LC_ALL="$LANG"
158    fi
159  else
160    unset LC_ALL
161  fi
162
163  if [ -n "$LANGUAGE" ]; then
164    if [ "$LANGUAGE" != "$LANG" ]; then
165      LANGUAGE="$LANG"
166    fi
167  else
168    unset LANGUAGE
169  fi
170
171  if [ -n "$LINGUAS" ]; then
172    if [ "$LINGUAS" != "$LANG" ]; then
173      LINGUAS="$LANG"
174    fi
175  else
176    unset LINGUAS
177  fi
178fi
179
180# run all system xinitrc shell scripts.
181if [ -d /etc/X11/xinit/xinitrc.d ]; then
182    for i in /etc/X11/xinit/xinitrc.d/* ; do
183        if [ -x "$i" ]; then
184            . "$i"
185        fi
186    done
187fi
188
189if [ "x$command" = "xcustom" ] ; then
190  if [ -x "$HOME/.xsession" ]; then
191    command="$HOME/.xsession"
192  else
193    echo "$0: Cannot find ~/.xsession will try the default session"
194    command="default"
195  fi
196fi
197
198if [ "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"
205  else
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"
209    else
210      echo "$0: Cannot find Xclients"
211    fi
212    exec xterm -geometry 80x24+0+0
213  fi
214fi
215
216# add ssh-agent if found
217sshagent="`gdmwhich ssh-agent`"
218if [ -n "$sshagent" ] && [ -x "$sshagent" ] && [ -z "$SSH_AUTH_SOCK" ]; then
219    command="$sshagent -- $command"
220elif [ -z "$sshagent" ] ; then
221    echo "$0: ssh-agent not found!"
222fi
223
224echo "$0: Setup done, will execute: $command"
225
226eval exec $command
227
228echo "$0: Executing $command failed, will run xterm"
229
230if [ -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"
233fi
234
235exec xterm -geometry 80x24+0+0
Note: See TracBrowser for help on using the repository browser.