#!/bin/sh
#------------------------------------------------------------------------------#
# Exec an xterm with random colors taken from ~/.colors.  Note that we use the #
# process  id  to  select  the color.  The alternate line uses the time, which #
# turns out to be undesirable because when run during login, all  the  windows #
# tend  to come up in one or two colors.  Also, note that if we can't find the #
# user's .colors file, we make one with a few generic  entries.   The  XColors #
# environment  variable  is  set up for the benefit of some other scripts that #
# use it.                                                                      #
#------------------------------------------------------------------------------#
F=$HOME/.colors
if [ ! -f $F ];then
	echo >$F ''
	echo>>$F '-bg black -fg red'
	echo>>$F '-bg black -fg green'
	echo>>$F '-bg black -fg blue'
	echo>>$F '-bg black -fg yellow'
	echo>>$F '-bg black -fg white'
	echo>>$F '-bg navy  -fg red'
	echo>>$F '-bg navy  -fg green'
	echo>>$F '-bg navy  -fg blue'
	echo>>$F '-bg navy  -fg yellow'
	echo>>$F '-bg navy  -fg white'
	if [ ! -f $F ];then
		echo "Can't find "$F" file."
		c=`-bg black -fg white`
	fi
fi
#m=`date +%H%M%S`
f='-fn 6x10'
m=$$
n=`wc -l<$F`
l=`expr $m % $n`
c=`head <$F -$l |tail -1`
XColors="$c";export XColors
echo `date` "xterm $c $f $*" |tee /dev/console >>$HOME/.xlog
exec /usr/bin/X11/xterm $c $f $*
exit 0
