#!/bin/sh


export TOTALTIME=1
export ARGS="-poll -rate 100000 -geometry +372+325"

if [ -z "$DISPLAY" ] ; then 
	exit
fi


#make sure the invokation knows to keep running for another TOTALTIME seconds.
date +%s > /tmp/dispvoldate

pids=`/bin/pidof tempmixer`

if [ "$pids" ] ; then
#already running one copy - we let it run for another TOTALTIME seconds, but quit ourselves
	exit
fi

tempmixer $ARGS &
while true ; do 
	sleep 1
	now=`date +%s`
	then=`cat /tmp/dispvoldate`
	timesofar=`expr "$now" - "$then"`
	if [ "$timesofar" -gt $TOTALTIME ] ; then
#		echo breaking
		break
	fi
#	echo looping
done
kill -HUP $!

