#!/bin/sh # Copyright: 2008 Sasa Bodiroza # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. DIR=$1; CUR_DIR=`pwd`; if [ -z $DIR ] ; then echo "Missing directory.\n"; exit 1; fi; cd $DIR; NUM=`find -maxdepth 1 -type f -regex ".+\.\(jpg\|jpeg\|gif\|png\|svg\)" -printf "%f\n" | wc -l` if [ $NUM -eq 0 ] ; then echo "Empty dir"; exit 1; fi INC=`expr 1440 \/ $NUM`; MOD=`expr 1440 \% $NUM`; CNT=1; CNT_MIN=0; while [ 1 ] ; do MIN=`date +%M`; HOUR=`date +%k`; CUR_MIN=`expr $MIN + $HOUR \* 60`; while [ $CNT -le $NUM ] ; do if [ $CUR_MIN -ge $CNT_MIN -a $CUR_MIN -lt `expr $CNT_MIN + $INC` ] ; then FILE=`pwd`/`find -maxdepth 1 -type f -regex ".+\.\(jpg\|jpeg\|gif\|png\|svg\)" -printf "%f\n" | sort | grep -n "" | grep "^$CNT" | cut -d: -f2`; # echo $FILE; gconftool-2 --type string --set /desktop/gnome/background/picture_filename "$FILE"; CNT=`expr $CNT + 1`; CNT_MIN=`expr $CNT_MIN + $INC`; break; fi CNT=`expr $CNT + 1`; CNT_MIN=`expr $CNT_MIN + $INC`; done if [ $MOD -ne 0 -a $CNT -gt $NUM ] ; then sleep `expr 1440 - $CUR_MIN`m; else sleep `expr $CNT_MIN - $CUR_MIN`m; fi if [ $CNT -gt $NUM ] ; then CNT=1; CNT_MIN=0; fi done