#!/bin/sh

# background.sh
# Handle the actual background rotation
# See the file LICENSE in the main distribution for license info
# Written by Matthew Fuller <fullermd@over-yonder.net>

# Grab the config files
# First, the global (this is set by the Makefile on install)
CONFDIR="/usr/local/etc"
export CONFDIR
. $CONFDIR/bgrot.conf

# And personal
if [ -f $DATADIR/bgrot.conf ]; then
	. $DATADIR/bgrot.conf
elif [ -f $HOME/.bgrotrc ]; then
	. $HOME/.bgrotrc
fi


while true
do
{
	$BINDIR/bgrandom.pl > $DATADIR/background.list
	for i in `cat $DATADIR/background.list`; do
		if [ -r $i ]; then
		xv -root -quit +nore $i
		sleep $DELAY
		fi
	done
}
done
