#!/bin/sh
# /usr/bin/X11/xsetroot -bg sgilightblue -bitmap /usr/include/X11/bitmaps/grainy

XAUTHORITY=/usr/lib/X11/xdm/xdm-auth export XAUTHORITY

#
# CAUTION:
# These two lines need to match those in /usr/bin/X11/X.
# NOT configurable on a per-user basis.
#
glGammaFile=/etc/config/system.glGammaVal
glGammaDefault="1.7"
GAMMA_CMD=/usr/sbin/gamma

#
# Execute gamma only for REX (starter) graphics.
#
if `hinv -c graphics | fgrep -s LG1` && [ -x "$GAMMA_CMD" ]; then
	RUN_GAMMA=1
fi

if [ "$RUN_GAMMA" = 1 ]; then
	if [ -r $glGammaFile -a -s $glGammaFile ];  then
		glGammaVal=`cat $glGammaFile`
	else
		glGammaVal=$glGammaDefault
	fi
fi

screens=`/usr/bin/X11/xlistscrns`
for screen in $screens
    do
	if [ "$RUN_GAMMA" = 1 ]; then
		HOME=/ DISPLAY=$screen /usr/sbin/gamma $glGammaVal
	fi
    done

/usr/bin/X11/xlistscrns -i

# visuallogin:  on: clogin;                  off: plain xdm login
# also, "-f" in clogin means grab input focus
if /etc/chkconfig visuallogin ; then
	if [ -x /usr/Cadmin/bin/clogin ] ; then
		exec /usr/Cadmin/bin/clogin -f
	fi
fi

