#!/bin/bash

SwitchTime=60
DirAnime=$(xdg-user-dir PICTURES)/dwm-anime-wallpaper/


[[ ! -z $(ps axf| grep $(basename $0)| grep -v grep ) ]] && exit

while true
	do 
		
		[[ ! -z ${1} ]] && RDir=$(ls -1 ${DirAnime}| grep ${1}) || RDir=$(ls -1 ${DirAnime} | sort -R | head -n1)
		Adate=$(date +%s)
		for Img in $(find "${DirAnime}"/"${RDir}"/ -name *.bmp | sort -n)
			do 
				feh --bg-scale "${Img}"
				#sleep 0.01
				Pdate=$(date +%s)
				[[ ${SwitchTime} -lt $((Pdate-Adate)) ]] && break
			done
	done


