All pastes #262012 Raw Edit

fluxbox_rotate_image

public shellscript v1 · immutable
#262012 ·published 2006-11-30 01:52 UTC
rendered paste body
##----fluxboxbg_rotate.sh - Background driver for dispbg with background image rotation########################    DECLARATIONS    #######################declare -i maximagesBACKGROUND_LIST=$1DELAY_RATE=$2###########################    END DECLARATIONS    ############################################################################################################################################    LOCAL FUNCTIONS    ##################################################################    FUNCTION BUILD_ROTATION_QUEUE    ########################################build_rotation_queue () {##----- Build or rebuild Background Image rotation queue#  maximages=0  rm -vf $LOGDIR/rotation_queue    if [ -f $BACKGROUND_LIST ]  then    echo "Found Image rotation list dispbg.rotation.list"    for filename in `grep -v \^# $BACKGROUND_LIST`    do      if [ -f $filename ]      then        maximages=`expr $maximages + 1`        echo "$filename" >> $LOGDIR/rotation_queue        file $filename        #jhead $filename        echo "Verified background Image # $maximages <$filename>.  Added to background image queue"      else        echo "Background Image $filename> not found.  Ignored."      fi # [ -f $filename ]    done # for filename in `grep -v \^# $BACKGROUND_LIST`  fi # [ -f $BACKGROUND_LIST ]  echo "maximages = <$maximages>"  if [ $maximages -gt 0 ]  then    echo "Total Images for queue"  else    echo "No Background Images found.  Continuing anyway since images can be added while looping"  fi # [ $maximages -gt 0 ]} # build_rotation_queue () {#####################################    FUNCTION CHECK_FOR_NEWLIST    #####################################check_for_newlist () {  newmd5sum="`md5sum $BACKGROUND_LIST|awk '{print $1}'`"  if [ $oldmd5sum = $newmd5sum ]  then    # echo "Unchanged rotation list old/new md5sum: $oldmd5sum $newmd5sum `date`"    RC="0"  else    echo "Rotation list changed old/new md5sum: $oldmd5sum $newmd5sum `date`"    build_rotation_queue    oldmd5sum=$newmd5sum    RC="1"  fi # if [ $oldmd5sum = $newmd5sum ]  return $RC} # check_for_newlist () ##############################    END LOCAL FUNCTIONS    ##############################################################################################################################    BEGIN MAIN    *#########################################    INITIALIZE    #####################echo "Start $0 `date`"rm -vf $LOGDIR/bgstopbuild_rotation_queue ####################    MAIN LOOP    ####################while [ ! -f $LOGDIR/bgstop ]do###############################################    BACKGROUND IMAGE ROTATION QUEUE LOOP    ###############################################  if [ $maximages -gt 0 ]  then    for background_image in `cat $LOGDIR/rotation_queue`    do      if [ -f $LOGDIR/bgstop ]      then        echo "Stop file found"        rm -vf $LOGDIR/bgstop        exit      fi      echo "Loading background image $background_image..."      wmsetbg -s -S  $background_image      sleep $DELAY_RATE       echo "Checking for new background list"      check_for_newlist      if [ $RC = "1" ]      then        break      fi     done # background_image in `cat rotation_queue`  else     sleep 5  # Need to sleep otherwise loops too fast until   fi # if [ $maximages -gt 0 ]done # while [ ! -f $LOGDIR/bgstop ]echo "Finished $0 `date`"