source: trunk/packs/dotfiles/xsession @ 20603

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