#!/bin/sh
#
# FILE NAME: start-ncd
#
# This is a simple start up script for using DEC's Xprompter and /etc/ttys
# login window. It will start a simple uwm unless a .start-ncd script exists in
# the user's home directory.
#
# The trick to doing all of this is to realize that the login process under 
# Ultrix reads the /etc/ttys file looking for lines beginning with ":number".
# For each such line, it will start a process with the first argument being
# the :number. To make it work with "arbitrary" units, start shell scripts 
# instead of programs. The NCD's you wish included must have names using 
# some numbering scheme that can be tied back to this ttys number.
#
# For example, start with a base name convention:

	BASENAME=ncdu

# Then read the ttys line of the format:
#
# :11 "/u/bin/login -P /u/local/xprompter-ncd -C /u/local/start-ncd" none on
#
# with the commands:

	NUMBER=`echo $1|sed 's/://'`
	UNIT=${BASENAME}${NUMBER}

# Use this to the set the X DISPLAY variable:

	DISPLAY=$UNIT:0
	export DISPLAY

# Now you are ready to really start the user's "session". A variety of 
# environments can be built; this is a simple example using a user's 
# own start up file, or a system default.
#
# Check for the existence of a .start-ncd file in the home dir:

	if test -f $HOME/.start-ncd
	then
		sh $HOME/.start-ncd $DISPLAY
	else
		uwm
	fi

# The only caveat to this mechanism at this point is that the user must
# truly stop all clients before the login banner will come back. (As you 
# would expect). Unfortunately there are no real "standard" means of enforcing
# this in a "friendly" manner. One mechanism is to just do an "xkill -a", but 
# this is not intuitively obvious or particularly safe.

