#!/bin/ksh -pu
#
# ident "@(#)utidle.sh	1.7 09/05/07 SMI"
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
# Examples:
#	/opt/SUNWut/lib/utidle /var/opt/SUNWUt/displays/9 true
#	/opt/SUNWut/lib/utidle /var/opt/SUNWUt/displays/121 false

ME=$0

# Parse arguments

eval $(sed -n 's/SESSION=\([^:]*\):\([^:\]*\):\(.*\)$/host=\1\
port=\2\
sid=\3/p' $1)

idle=$2

if [ -z "$host" -o -z "$port" -o -z "$sid" -o -z "$idle" ]
then
	exit 1;
fi


UTLIB=/etc/opt/SUNWut/basedir/lib
UTPIPE=${UTLIB}/utnetpipe

print "control $host:$port:$sid\nrequest annotate\nidle=$idle\nend\n" \
| $UTPIPE $host 7010 > /dev/null 2>&1

#
# we just send the message, we don't need to confirm.
#

exit 0
