#!/bin/sh
# A simple bash script to screen capture
#
# Supply arguments: 
#	window id
#	number of captures
#	delay in animation
#	quality of encoding

let x=1

# loop until it has captured the number of captures requested
while [ $x -le $2 ]
do
  if [ $x -lt 100 ]
  then
    if [ $x -lt 10 ]
    then
      import -window $1 "capture00$x.miff"
    else
      import -window $1 "capture0$x.miff"
    fi
  else
    import -window $1 "capture$x.miff"
  fi
  
  # uncomment the line below
  # if you want more time in between screen captures
# sleep 2s  
  let x+=1
done

#animate -delay $3 *.miff
#convert -delay $3 -quality $4 *.miff capture.mpg
