#!/bin/bash
#
#script changes wallpaper with wallpapersetter like a fbsetbg, but without installs of a fluxbox.

setwall ()	{
	 	${WSETTER} ${WSETTER_OPT} "$WALLDIR/${arrwall[$IND]}" &> /dev/null 
	echo `expr $IND + 1` > $TMP	
		};

TMP="/tmp/wsetter.count"
WSETTER=feh
WSETTER_OPT="--bg-fill" 
WALLDIR="${HOME}/wallpapers"
IND=`cat "$TMP"`
NUMWALL=`ls -1 "${WALLDIR}" | wc -l`
LIST=`ls -1 ${WALLDIR} | xargs`

#echo NUMWALL is $NUMWALL
#echo TMP is $TMP
#echo IND is $IND
#echo LIST is ${LIST};

declare -a arrwall=(${LIST})
#echo arrwall is ${arrwall[*]}


if [ ! -f "$TMP" ]; then 
	echo 0 > "$TMP";
fi

#echo `basename $0`: ind $IND numvol $NUMWALL

if [  "$IND" -ge "$NUMWALL" ]; then 
IND=0
echo 0 > "$TMP";
fi

setwall || exit 100



exit 0


