source: trunk/debathena/debathena/dotfiles/xsession @ 23823

Revision 23823, 11.0 KB checked in by geofft, 15 years ago (diff)
In dotfiles: * Don't run 'from' on EXCHANGE.MIT.EDU accounts for now. This is apparently causing prefrosh' dotfiles to hang forever on login.
Line 
1#!/bin/tcsh -f
2# Global xsession file
3# Accepts one optional argument, either "nocalls" (use no user files)
4# or "dash" (use old dash-based interface).
5#
6# $Id: xsession,v 1.28 2007-08-22 18:11:08 ghudson Exp $
7
8# Note: This shell script deliberately uses the -f flag.
9
10set initdir=/usr/lib/init
11set gconftool=/usr/bin/gconftool-2
12
13# Determine whether to use user customizations:  use no customization files
14# ONLY if the single argument "nocalls" was provided to xsession (e.g., if
15# the user selected the "Ignore your customizations" option from the
16# initial xlogin menu).
17
18switch ($#argv)
19case 0:
20  breaksw
21case 1:
22  if (($1 == nocalls) || ($1 == -nocalls)) then
23    echo -n "xsession: Running standard xsession "
24    echo "with NO user configuration files..."
25    setenv NOCALLS
26    setenv SHELL /bin/tcsh
27  else if ($1 == dash) then
28    echo -n "xsession: Running standard xsession "
29    echo "with dash-based interface..."
30    setenv ATHENA_DASH_INTERFACE
31  else
32    set bad_args
33  endif
34  breaksw
35default:
36  set bad_args
37endsw
38
39if ($?bad_args) then
40  echo "xsession: Arguments ($argv) not recognized."
41  echo "Running standard xsession with user configuration files..."
42  unsetenv NOCALLS
43  unset bad_args
44endif
45
46# Echo messages unless user has ~/.hushlogin file AND the session was not
47# started using the xlogin "SYSTEM" option.
48
49if ((! -r ~/.hushlogin) || ($?NOCALLS)) set verbose_login
50
51
52# Use old dash-based interface if the user has
53# ~/.athena_dash_interface and the session was not started with
54# NOCALLS.
55
56if (-r ~/.athena_dash_interface && ! $?NOCALLS) then
57  setenv ATHENA_DASH_INTERFACE
58endif
59
60# *******************   ENVIRONMENT SETUP   *******************
61
62
63# Identify this as a window session.
64
65setenv XSESSION $$
66
67# We set sleep_time to 0 for historical purposes, in case anyone has
68# code that depends on its value.
69
70set sleep_time=0
71
72# The ~/.cshrc file sets environment variables, attaches lockers, and sets
73# the command search path.
74
75if ($?verbose_login) echo "Setting up environment..."
76
77# Source the system startup scripts if necessary.
78if (-r /etc/.login) source /etc/.login
79if (-r /etc/.cshrc) source /etc/.cshrc
80if (-r /etc/csh.login) source /etc/csh.login
81if (-r /etc/csh.cshrc) source /etc/csh.cshrc
82
83if ($?NOCALLS) then
84  if (-r ${initdir}/cshrc) source ${initdir}/cshrc
85else
86  if (-r ~/.cshrc) then
87    source ~/.cshrc
88  else
89    if (-r ${initdir}/cshrc) source ${initdir}/cshrc
90  endif
91endif
92
93if ($?ATHENA_DASH_INTERFACE) then
94  set default_windowmanager=mwm
95  set terminal='xterm -geometry 80x48+0+38'
96else
97  set default_windowmanager=metacity
98  set terminal='gnome-terminal --geometry=80x40-0-52'
99
100  # GNOME processes can apparently collide trying to start gconfd, so
101  # spawn one before we start any in the background.
102  $gconftool --spawn
103endif
104
105
106# *******************   DEVICE SETUP   *******************
107
108# Load user X resources.
109
110if ((! $?NOCALLS) && (-r ~/.Xresources)) xrdb -merge ~/.Xresources
111
112
113# *******************   ACTIVITY STARTUP   *******************
114
115if ( ! $?NOCALLS && -d ~/.gnome && ! -d ~/.gnome2 ) set offer_gnome_upgrade
116
117# Start window manager.  To change your default window manager, set the
118# WINDOW_MANAGER environment variable in your ~/.environment file.
119if ($?WINDOW_MANAGER) then
120  setenv ATHENA_ENV_WINDOW_MANAGER
121else if ( -r ~/.athena-sawfish ) then
122  setenv WINDOW_MANAGER sawfish
123else
124  setenv WINDOW_MANAGER $default_windowmanager
125endif
126
127if ($?verbose_login) echo "Starting $WINDOW_MANAGER window manager..."
128
129if ($?NOCALLS) then
130  (metacity >& /dev/null &)
131else
132  ($WINDOW_MANAGER >& /dev/null &)
133endif
134
135# Run standard system/user startup activities
136
137if ( -r ~/.athena_gnome_convert_failure ) then
138  # A previous attempt at converting GNOME preferences failed.  Remove
139  # any GNOME 2 preferences so that the user gets the defaults.
140  $gconftool --recursive-unset /apps
141  $gconftool --recursive-unset /desktop
142  $gconftool --recursive-unset /system
143  rm -rf ~/.gnome2
144  rm -f ~/.athena_gnome_convert_failure
145else if ($?offer_gnome_upgrade) then
146  set dtext = ( \
147    "\n" \
148    " This Athena release uses GNOME 2, which changes the way the  \n" \
149    " desktop is configured.  You can attempt to convert your GNOME 1  \n" \
150    " preferences, or you can just accept the defaults for GNOME 2.  \n" \
151    " If you do attempt to convert, you will be given a chance to go  \n" \
152    " back to the defaults if it doesn't work well.\n" \
153    "\n" \
154    " Do you wish to attempt to convert your preferences?\n" )
155  if ( { gdialog --title "GNOME upgrade check" --yesno "$dtext" 9 70 } ) then
156    touch ~/.athena-gnome-upgrade-log
157    echo "Attempting GNOME upgrade on `date`" >> ~/.athena-gnome-upgrade-log
158    bash $initdir/gnome-stuff-1-to-2 >>& ~/.athena-gnome-upgrade-log
159    perl $initdir/gnome-panel-1-to-2 >>& ~/.athena-gnome-upgrade-log
160    set offer_gnome_failure
161  endif
162  unset dtext
163endif
164
165if ( ! $?ATHENA_DASH_INTERFACE) then
166  # Run gnome-settings-daemon unless the user has chosen to skip it.
167  # (We used to run a series of capplets with an init flag; thus the
168  # skip variable is named skip_capplets.)
169  if (! $?skip_capplets) then
170    if ($?verbose_login) echo "Initializing settings..."
171
172    # This incantation causes gnome-settings-daemon to be run via
173    # Bonobo, such that we won't continue until the settings-daemon
174    # object has been initialized and all settings have been
175    # propagated.  If we just naively run gnome-settings-daemon in the
176    # background, settings may not propagate before GNOME programs
177    # run.  In particular, GNOME programs might render text before the
178    # Xft settings have been propagated, leading to incorrect font
179    # selection.
180    activation-client -s "iid == 'OAFIID:GNOME_SettingsDaemon'" > /dev/null
181  endif
182
183  if ((! $?ATHENA_ENV_WINDOW_MANAGER) && (! -r ~/.athena-sawfish) \
184      && (-r ~/.sawfish) && (! -r ~/.athena-wm-upgrade-dialog)) then
185    touch ~/.athena-wm-upgrade-dialog
186    zenity --info --text='This Athena release has changed the default window manager from Sawfish to Metacity.  Metacity is faster, more stable, and better-integrated with GNOME than Sawfish, but is not as customizable.\n\nIf you wish to continue using Sawfish, you may do so by selecting Settings -> Revert to Sawfish Window Manager from the foot menu.'
187  endif
188
189  # Run the GNOME panel unless the user has chosen to skip it.  For
190  # compatibility, if the user elected to skip both dash and xlogout
191  # in the old dash-based world, skip panel now.  TODO: deal with
192  # NOCALLS; add logout confirmation
193  if (! $?skip_panel && ! ($?skip_dash && $?skip_xlogout)) then
194    if ($?verbose_login) echo "Starting panel..."
195    (gnome-panel >& /dev/null && kill -HUP $XSESSION &)
196  endif
197
198  # If you decide to set skip_nautilus, GNOME will stop taking care
199  # of your background image unless you run:
200  #   gconftool-2 -s -t bool /apps/nautilus/preferences/show_desktop false
201  if (! $?skip_nautilus ) then
202    (nautilus -n >& /dev/null &)
203  endif
204
205else if (! $?skip_dash) then
206  if (! $?skip_xlogout) then
207    if ($?verbose_login) echo "Starting the Athena Dashboard..."
208    if ($?verbose_login) echo "Creating logout button..."
209    (dash -default -logout &)
210  else
211    if ($?verbose_login) echo "Starting the Athena Dashboard..."
212    (dash &)
213  endif
214else if (! $?skip_xlogout) then
215  if ($?verbose_login) echo "Creating logout button..."
216  (dash -logout &)
217endif
218
219# Start default initial xterm window.  To skip this, put the command
220# "set skip_initial_xterm" in your ~/.environment file.
221
222# BE CAREFUL:  If you skip this, make sure that your ~/.startup.X file
223# provides a way for you to exit your session (e.g., an xterm from which
224# you can type "logout").
225
226if (! $?skip_initial_xterm) then
227  if ($?verbose_login) echo "Creating initial xterm window..."
228  ($terminal >& /dev/null &)
229endif
230
231# Run default system startup activities.  To skip these, put the command
232# "set skip_x_startup" in your ~/.environment file.
233
234if (! $?skip_x_startup) then
235  if ($?verbose_login) echo "Running standard startup activities..."
236  # Start Zephyr client, and if zephyr started okay, send message of
237  # the day as windowgram
238  if (! $?ZEPHYR_CLIENT) setenv ZEPHYR_CLIENT zwgc
239  if ($?NOCALLS) then
240    zwgc -f /etc/zephyr/zwgc.desc -subfile /dev/null && \
241      get_message -new -zephyr
242  else
243    $ZEPHYR_CLIENT && get_message -new -zephyr
244  endif
245  if (! $?skip_quotawarn) then
246    ($initdir/quotawarn &)      # Display warning dialogs if near quota
247  endif
248  if ("`hesinfo $USER pobox`" !~ "*EXCHANGE*") then
249    from.debathena -t -n        # Check for mail
250  endif
251  if (! $?skip_xss) then
252    (xscreensaver -no-splash &)
253  endif
254  # Note: authwatch uses the present value of $KRB5CCNAME, which may
255  # be modified by ~/.environment.  However, if bash users make a
256  # similar change in ~/.bash_environment, that change will NOT be
257  # seen by this invocation of authwatch.
258  if (! $?skip_authwatch) then
259    (authwatch &)
260  endif
261endif
262
263# Maybe start the Disco-Athena daemon.
264if (-r /var/run/athstatusd.sock && ! $?skip_athneteventd) athneteventd
265
266# Run the window-session customizing commands in your ~/.startup.X
267# file.  We want to background this process in case something in the
268# startup hangs.  Thus, the user will not be left with active windows
269# and no method of easily logging out.
270
271# We also run the notification system, lert. Ideally, we wish the user
272# to receive the alert in the form of a zephyrgram, and since they may
273# run zwgc from their .startup.X, we wait until that has finished.  To
274# skip lert (a generally bad idea unless you plan to run it yourself -
275# it is not at all intended for frivolous messages), put the command
276# "set skip_lert" in your ~/.environment file.
277
278if ((! $?NOCALLS) && (-r ~/.startup.X)) then
279  if ($?verbose_login) then
280    echo "Running custom startup activities listed in ~/.startup.X..."
281  endif
282  ( source ~/.startup.X; \
283    if (! $?skip_lert) lert -q -z ; \
284    if ($?verbose_login) echo "Session initialization completed." & )
285else
286  if (! $?skip_lert) lert -q -z
287  echo "Session initialization completed."
288endif
289
290if ($?offer_gnome_failure) then
291  set dtext = ( \
292    "\n" \
293    " If the conversion went well, your desktop should look about the  \n" \
294    " same as it used to.  If not, you might be missing panel buttons  \n" \
295    " or other elements of the desktop.  \n" \
296    "\n" \
297    " Do you wish to keep the results of the conversion?\n" )
298  if ( ! { gdialog --title "GNOME failure check" --yesno "$dtext" 7 70 } ) then
299    set dtext = ( \
300      "\n" \
301      " You will now be logged out.  On your next login, you will  \n" \
302      " receive the GNOME 2 defaults.  \n" )
303    gdialog --infobox "$dtext" 4 70
304    touch ~/.athena_gnome_convert_failure
305    exit
306  endif
307  unset dtext
308endif
309
310
311# Gate the session.
312
313# This command replaces this script and will wait for you to log out.
314# To terminate this process, logout (type the "logout" command in any
315# xterm window, use the Logout button, or select the "Logout of
316# Athena" option from Dash), or invoke the "end_session" program.
317
318if ($?NOCALLS) then
319  exec session_gate
320else
321  exec session_gate -logout
322endif
323
324# The session gate will source .logout when it gets a SIGHUP, if
325# invoked with the -logout flag.
Note: See TracBrowser for help on using the repository browser.