#!/bin/bash

mostrecent=`ls -t Jones/*.tif | head -n 1 2>/dev/null`
if [ $? = 0 ]; then
  lastfile=$mostrecent
else
  lastfile=
fi
disp=

while [ 1 -gt 0 ]; do
  if [ -s "$lastfile" -a -z "$disp" ]; then
    display $lastfile &
    disp=$!
  fi
  mostrecent=`ls -t Jones/*.tif | head -n 1 2>/dev/null`
  if [ $? != 0 ]; then
    sleep 2
  elif [ ! -s $mostrecent ]; then
    sleep 2
  elif [ "$mostrecent" = "$lastfile" ]; then
    sleep 2
  else
    lastfile=$mostrecent
    kill $disp
    disp=
  fi
done
