source: trunk/packs/dotfiles/xsession @ 21187

Revision 21187, 11.2 KB checked in by ghudson, 20 years ago (diff)
Change the default window manager from Sawfish to Metacity, and provide a script (to be called by a menu item under Settings) to let users revert to Sawfish if they want.
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.21 2004-12-17 00:18:21 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=metacity
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) then
122  setenv ATHENA_ENVIRONMENT_WINDOW_MANAGER
123else if ( -r ~/.athena-sawfish ) then
124  setenv WINDOW_MANAGER sawfish
125else
126  setenv WINDOW_MANAGER $default_windowmanager
127endif
128
129if ($?verbose_login) echo "Starting $WINDOW_MANAGER window manager..."
130
131if ($?NOCALLS) then
132  (metacity &)
133else
134  ($WINDOW_MANAGER &)
135endif
136
137# Run standard system/user startup activities
138
139set gconftool=/usr/athena/bin/gconftool-2
140
141if ( -r ~/.athena_gnome_convert_failure ) then
142  # A previous attempt at converting GNOME preferences failed.  Remove
143  # any GNOME 2 preferences so that the user gets the defaults.
144  $gconftool --recursive-unset /apps
145  $gconftool --recursive-unset /desktop
146  $gconftool --recursive-unset /system
147  rm -rf ~/.gnome2
148  rm -f ~/.athena_gnome_convert_failure
149else if ($?offer_gnome_upgrade) then
150  set dtext = ( \
151    "\n" \
152    " This Athena release uses GNOME 2, which changes the way the  \n" \
153    " desktop is configured.  You can attempt to convert your GNOME 1  \n" \
154    " preferences, or you can just accept the defaults for GNOME 2.  \n" \
155    " If you do attempt to convert, you will be given a chance to go  \n" \
156    " back to the defaults if it doesn't work well.\n" \
157    "\n" \
158    " Do you wish to attempt to convert your preferences?\n" )
159  if ( { gdialog --title "GNOME upgrade check" --yesno "$dtext" 9 70 } ) then
160    touch ~/.athena-gnome-upgrade-log
161    echo "Attempting GNOME upgrade on `date`" >> ~/.athena-gnome-upgrade-log
162    bash $initdir/gnome-stuff-1-to-2 >>& ~/.athena-gnome-upgrade-log
163    perl $initdir/gnome-panel-1-to-2 >>& ~/.athena-gnome-upgrade-log
164    set offer_gnome_failure
165  endif
166  unset dtext
167endif
168
169if ( ! $?ATHENA_DASH_INTERFACE) then
170  # GNOME processes can apparently collide trying to start gconfd, so
171  # spawn one before we start any in the background.
172  $gconftool --spawn
173
174  # Run gnome-settings-daemon unless the user has chosen to skip it.
175  # (We used to run a series of capplets with an init flag; thus the
176  # skip variable is named skip_capplets.)
177  if (! $?skip_capplets) then
178    if ($?verbose_login) echo "Initializing settings..."
179
180    # This incantation causes gnome-settings-daemon to be run via
181    # Bonobo, such that we won't continue until the settings-daemon
182    # object has been initialized and all settings have been
183    # propagated.  If we just naively run gnome-settings-daemon in the
184    # background, settings may not propagate before GNOME programs
185    # run.  In particular, GNOME programs might render text before the
186    # Xft settings have been propagated, leading to incorrect font
187    # selection.
188    activation-client -s "iid == 'OAFIID:GNOME_SettingsDaemon'" > /dev/null
189  endif
190
191  if ((! $?ATHENA_ENVIRONMENT_WINDOW_MANAGER) && (! -r ~/.athena-sawfish) \
192      && (-r ~/.sawfish) && (! -r ~/.athena-wm-upgrade-dialog)) then
193    touch ~/.athena-wm-upgrade-dialog
194    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.'
195  endif
196
197  # Run the GNOME panel unless the user has chosen to skip it.  For
198  # compatibility, if the user elected to skip both dash and xlogout
199  # in the old dash-based world, skip panel now.  TODO: deal with
200  # NOCALLS; add logout confirmation
201  if (! $?skip_panel && ! ($?skip_dash && $?skip_xlogout)) then
202    if ($?verbose_login) echo "Starting panel..."
203    (gnome-panel >& /dev/null && kill -HUP $XSESSION &)
204  endif
205
206  # If you decide to set skip_nautilus, GNOME will stop taking care
207  # of your background image unless you run:
208  #   gconftool-2 -s -t bool /apps/nautilus/preferences/show_desktop false
209  if (! $?skip_nautilus ) then
210    (nautilus -n >& /dev/null &)
211  endif
212
213else if (! $?skip_dash) then
214  if (! $?skip_xlogout) then
215    if ($?verbose_login) echo "Starting the Athena Dashboard..."
216    if ($?verbose_login) echo "Creating logout button..."
217    (dash -default -logout &)
218  else
219    if ($?verbose_login) echo "Starting the Athena Dashboard..."
220    (dash &)
221  endif
222else if (! $?skip_xlogout) then
223  if ($?verbose_login) echo "Creating logout button..."
224  (dash -logout &)
225endif
226
227# Start default initial xterm window.  To skip this, put the command
228# "set skip_initial_xterm" in your ~/.environment file.
229
230# BE CAREFUL:  If you skip this, make sure that your ~/.startup.X file
231# provides a way for you to exit your session (e.g., an xterm from which
232# you can type "logout").
233
234if (! $?skip_initial_xterm) then
235  if ($?verbose_login) echo "Creating initial xterm window..."
236  ($terminal >& /dev/null &)
237endif
238
239# Run default system startup activities.  To skip these, put the command
240# "set skip_x_startup" in your ~/.environment file.
241
242if (! $?skip_x_startup) then
243  if ($?verbose_login) echo "Running standard startup activities..."
244  # Start Zephyr client, and if zephyr started okay, send message of
245  # the day as windowgram
246  if (! $?ZEPHYR_CLIENT) setenv ZEPHYR_CLIENT zwgc
247  if ($?NOCALLS) then
248    zwgc -f /usr/athena/share/zephyr/zwgc.desc -subfile /dev/null && \
249      get_message -new -zephyr
250  else
251    $ZEPHYR_CLIENT && get_message -new -zephyr
252  endif
253  mailquota -n                  # Check quota on post office server
254  from -t -n                    # Check for mail
255  (olc who &) >& /dev/null      # Ping the OLC server
256  if (! $?skip_xss) then
257    (xscreensaver -no-splash &)
258  endif
259  # Note: authwatch uses the present value of $KRB5CCNAME, which may
260  # be modified by ~/.environment.  However, if bash users make a
261  # similar change in ~/.bash_environment, that change will NOT be
262  # seen by this invocation of authwatch.
263  if (! $?skip_authwatch) then
264    (authwatch &)
265  endif
266endif
267
268# Maybe start the Disco-Athena daemon.
269if (-r /var/run/athstatusd.sock && ! $?skip_athneteventd) athneteventd
270
271# Run the window-session customizing commands in your ~/.startup.X
272# file.  We want to background this process in case something in the
273# startup hangs.  Thus, the user will not be left with active windows
274# and no method of easily logging out.
275
276# We also run the notification system, lert. Ideally, we wish the user
277# to receive the alert in the form of a zephyrgram, and since they may
278# run zwgc from their .startup.X, we wait until that has finished.  To
279# skip lert (a generally bad idea unless you plan to run it yourself -
280# it is not at all intended for frivolous messages), put the command
281# "set skip_lert" in your ~/.environment file.
282
283if ((! $?NOCALLS) && (-r ~/.startup.X)) then
284  if ($?verbose_login) then
285    echo "Running custom startup activities listed in ~/.startup.X..."
286  endif
287  ( source ~/.startup.X; \
288    if (! $?skip_lert) lert -q -z ; \
289    if ($?verbose_login) echo "Session initialization completed." & )
290else
291  if (! $?skip_lert) lert -q -z
292  echo "Session initialization completed."
293endif
294
295if ($?offer_gnome_failure) then
296  set dtext = ( \
297    "\n" \
298    " If the conversion went well, your desktop should look about the  \n" \
299    " same as it used to.  If not, you might be missing panel buttons  \n" \
300    " or other elements of the desktop.  \n" \
301    "\n" \
302    " Do you wish to keep the results of the conversion?\n" )
303  if ( ! { gdialog --title "GNOME failure check" --yesno "$dtext" 7 70 } ) then
304    set dtext = ( \
305      "\n" \
306      " You will now be logged out.  On your next login, you will  \n" \
307      " receive the GNOME 2 defaults.  \n" )
308    gdialog --infobox "$dtext" 4 70
309    touch ~/.athena_gnome_convert_failure
310    exit
311  endif
312  unset dtext
313endif
314
315
316# Gate the session.
317
318# This command replaces this script and will wait for you to log out.
319# To terminate this process, logout (type the "logout" command in any
320# xterm window, use the Logout button, or select the "Logout of
321# Athena" option from Dash), or invoke the "end_session" program.
322
323if ($?NOCALLS) then
324  exec session_gate
325else
326  exec session_gate -logout
327endif
328
329# The session gate will source .logout when it gets a SIGHUP, if
330# invoked with the -logout flag.
Note: See TracBrowser for help on using the repository browser.