#!/bin/ksh -p
#
# ident "@(#)gdm-notify.sh	1.1 04/04/14"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
#
# Script to notify gdm that the Xservers file and  Xconfig file have changed
#

verbose=0
umask 0022
DMNAME=gdm-binary
unset LD_LIBRARY_PATH
BASE=/etc/opt/SUNWut/basedir
SUNWUTLIB=$BASE/lib
XSUN=$SUNWUTLIB/utxsun

GDMDYN=/usr/bin/gdmdynamic

if [ $# -eq  1 ]
then
	dpy=$1
else
	exit
fi

#
# since SRSS is started in rc 5 scripts and
# gdm is started out of inittab, we cannot
# be certain that gdm is running
#

count=1000

while [[ $count -gt 0 ]]
do
	count=$(($count-1))
	pgrep -P 1 -u 0 $DMNAME >/dev/null
	if [[ $? -ne 0 ]]
	then
		sleep 15
	else
		count=0
	fi
done

cmd="$dpy""=""$XSUN"
($GDMDYN -a $cmd; $GDMDYN -r $dpy)&

