head	1.1;
access;
symbols;
locks; strict;
comment	@# @;


1.1
date	95.03.23.02.51.45;	author svalente;	state Exp;
branches;
next	;


desc
@xsession
@


1.1
log
@Initial revision
@
text
@#!/bin/athena/tcsh -f
# Global xsession file
# Accepts one optional argument "nocalls" (i.e., use no user files)
#
# $Id: xsession,v 1.40 1995/01/27 04:10:18 cfields Exp cfields $

# Note: This shell script deliberately uses the -f flag.

set initdir=/usr/athena/lib/init

# Determine whether to use user customizations:  use no customization files
# ONLY if the single argument "nocalls" was provided to xsession (e.g., if
# the user selected the "Ignore your customizations" option from the
# initial xlogin menu).

switch ($#argv)
    case 0:
        breaksw
    case 1:
        if (($1 == nocalls) || ($1 == -nocalls)) then
            echo -n "xsession: Running standard xsession "
            echo "with NO user configuration files..."
            setenv NOCALLS
	    setenv SHELL /bin/athena/tcsh
        else
            set bad_args
        endif
        breaksw
    default:
        set bad_args
endsw

if ($?bad_args) then
        echo "xsession: Arguments ($argv) not recognized."
        echo "Running standard xsession with user configuration files..."
        unsetenv NOCALLS
        unset bad_args
endif


# Do not echo status messages if noninteractive shell.  For interactive shells,
# echo messages unless user has ~/.hushlogin file AND the session was not 
# started using the xlogin "SYSTEM" option.

	if ((! -r ~/.hushlogin) || ($?NOCALLS)) set verbose_login


# *******************   ENVIRONMENT SETUP   *******************


# Identify this as a window session.

setenv XSESSION $$

# Set the sleep time for waiting between launching large applications.
# These are only set for "slow" machines.  They can be overridden in
# the ~/.cshrc.mine or ~/.environment files. 

set sleep_time=1
switch ("`machtype -c`")
    case VAXSTAR:
	set sleep_time=10
	breaksw
    case CVAXSTAR:
	set sleep_time=3
	breaksw
    case MVAX-II:
	set sleep_time=10
	breaksw
    case RTPC-*:
	set sleep_time=6
	breaksw
    case PS2-*:
	set sleep_time=6
	breaksw
    default:
	set sleep_time=0
endsw

# The ~/.cshrc file sets environment variables, attaches lockers, and sets
# the command search path.

if ($?verbose_login) echo "Setting up environment..."

if ($?NOCALLS) then
	if (-r ${initdir}/cshrc) source ${initdir}/cshrc
else
	if (-r ~/.cshrc) then
		source ~/.cshrc
	else 
		if (-r ${initdir}/cshrc) source ${initdir}/cshrc
	endif
endif



# *******************   DEVICE SETUP   *******************


# Load user X resources.

if ((! $?NOCALLS) && (-r ~/.Xresources)) xrdb -merge ~/.Xresources


# Start window manager.  To change your default window manager, set the 
# WINDOW_MANAGER environment variable in your ~/.environment file.

if (! $?WINDOW_MANAGER) setenv WINDOW_MANAGER mwm
if ($?verbose_login) echo "Starting $WINDOW_MANAGER window manager..."

if ($?NOCALLS) then
	(mwm -xrm "*configFile: /usr/athena/lib/X11/system.mwmrc" &)
	sleep $sleep_time
	sleep $sleep_time
else
	($WINDOW_MANAGER &)
	sleep $sleep_time
	# mwm takes twice as long to start
	if ("$WINDOW_MANAGER" =~ mwm) sleep $sleep_time	
endif


# *******************   ACTIVITY STARTUP   *******************

# Run standard system/user startup activities


# Run the Athena Dashboard by default.
# To skip this, put the command "set skip_dash" in
# your ~/.environment file.

# Also run the Athena Dashboard as the logout button.
# To skip this, put the command "set skip_xlogout" in
# your ~/.environment file.

# We run this first, before the initial xterm, to give dash a chance to
# start up and be ready to put up the logout button later (below).

if (! $?skip_dash) then
	if (! $?skip_xlogout) then
		if ($?verbose_login) echo "Starting the Athena Dashboard..."
		if ($?verbose_login) echo "Creating logout button..."
		if ($?NOCALLS) then
			(dash -default -logout \
			    -userdefs /usr/athena/lib/X11/app-defaults/Dash &)
		else
			(dash -default -logout &)
		endif
		sleep $sleep_time
	else
		if ($?verbose_login) echo "Starting the Athena Dashboard..."
		(dash &)
		sleep $sleep_time
	endif
else
	if (! $?skip_xlogout) then
		if ($?verbose_login) echo "Creating logout button..."
		(dash -logout &)
		sleep $sleep_time
	endif
				
endif

# Start default initial xterm window.  To skip this, put the command
# "set skip_initial_xterm" in your ~/.environment file.

# BE CAREFUL:  If you skip this, make sure that your ~/.startup.X file
# provides a way for you to exit your session (e.g., an xterm from which
# you can type "logout"). 

if (! $?skip_initial_xterm) then
	if ($?verbose_login) echo "Creating initial xterm window..."
	(xterm -geometry 80x48+0+30 &)
	sleep $sleep_time
endif

# Run default system startup activities.  To skip these, put the command
# "set skip_x_startup" in your ~/.environment file.

if (! $?skip_x_startup) then
	if ($?verbose_login) echo "Running standard startup activities..."
	# Start Zephyr client, and if zephyr started okay, send
	# message of the day as windowgram
	if ($?NOCALLS) then
		zwgc -f /usr/athena/lib/zephyr/zwgc.desc \
				-subfile /dev/null && \
		get_message -new -zephyr
	else
		zwgc && get_message -new -zephyr
	endif
	from -t -n			# Check for mail
	(olc who &) >& /dev/null	# Ping the OLC server
endif


# Run the window-session customizing commands in your ~/.startup.X file.
# We want to background this process in case something in the startup
# hangs.  Thus, the user will not be left with active windows and no
# method of easily logging out.

# We also run the notification system, lert. Ideally, we wish the user
# to receive the alert in the form of a zephyrgram, and since they may
# run zwgc from their .startup.X, we wait until that has finished.
# To skip lert (a generally bad idea unless you plan to run it yourself -
# it is not at all intended for frivolous messages), put the commend
# "set skip_lert" in your ~/.environment file.

if ((! $?NOCALLS) && (-r ~/.startup.X)) then
	if ($?verbose_login) then
	  echo "Running custom startup activities listed in ~/.startup.X..."
	endif
	( source ~/.startup.X; \
	  if (! $?skip_lert) lert -q -z ; \
	  if ($?verbose_login) echo "Session initialization completed." &)
else
	if (! $?skip_lert) lert -q -z
	echo "Session initialization completed."
endif


# Gate the session.

# This command replaces this script and will wait for you to log out.
# To terminate this process, logout (type the "logout" command in any
# xterm window, use the Logout button, or select the "Logout of Athena"
# option from Dash), or invoke the "end_session" program.

if ($?NOCALLS) then
	exec session_gate
else
	exec session_gate -logout
endif

# The session gate will source .logout when it gets a SIGHUP, if
# invoked with the -logout flag.
@
