#! /bin/sh
# $Header:xwin 12.0$ 
# $ACIS:xwin 12.0$ 
# $Source: /ibm/acis/usr/src/usr.skel/RCS/xwin,v $ 
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# Simple X setup. Write optional X clients into a temp file and
# startup xinit optionally pointing it at this file.
# The default is to start up Xibm with uwm as the window manager
# and one xterm as a user shell window.

# If -cwm or -uwm is specified more than once, only the last one is used.

USAGE="Usage: `basename $0` [-uwm|-cwm] [-xclock] [-xload]"

TFILE=/tmp/Xtmp$$		# Mame of temp file.
trap "rm -f $TFILE" 0 2		# Remove temp file in certain conditions.

# Default window manager. Change to preferred default if desired.
WM='uwm &'

# Case switch for xclients. To add another option follow the
# example flag cases below:
for i
do
	case "$i" in
	-uwm)		WM='uwm &';;
	-cwm)		WM='cwm &';;
	-xclock)	XCLOCK='xclock =100x100-0-0 -analog &';;
	-xload)		XLOAD='xload =-0+0 &';;
	*)		exec echo $USAGE >&2;;
	esac
done

# Finish writing the temp file. Xterm always goes in the temp file.
# THE LAST COMMAND IN THIS LIST SHOULD NOT BE BACKGROUNDED
# othewise xinit will kill everying and exit immediately after starting
# last command.
echo "#! /bin/sh
$XCLOCK
$XLOAD
$WM
xterm -sb -sl 1000 -bw 1 =60x24+0+0 -n xterm -fn 9x15
" >> $TFILE

# The temp file must be executable.
chmod 755 $TFILE
	
# If DISPLAY environment is not defined, set it to :0 to make clients
# like xterm happy, otherwise use the defined value.
DISPLAY=${DISPLAY-:0}
export DISPLAY

# Start up xinit which in turn starts our X environment reading a list
# of clients to startup from $TFILE.
xinit $TFILE -- Xibm
