#####!/bin/bash # imgdump.sh 11/26/09 # Periodically dumps an app window as a series of gif files # Requires import from the imagemagick package # Requires wmctrl to automatically focus window # Usage: Edit below to set dump interval in seconds or to change names # Window name must match the running app exactly, app must be running # Run script to start recording, first image saved after 10 seconds # Run script again to stop recording (removes the dump_running file) # File numbers start at 1000, delete imgdump.ini to reset count # -------- setup -------------- outdir="imgdump" # name of directory to save images to ininame="imgdump.ini" # name of file to record image number runfile="dump_running" # name of file to indicate script is running window="mevo" # name of window to dump interval=60 # number of seconds between dumps fbase="dump" # base name for images fext=".gif" # extension for images n=1000 # starting number for images # ----------------------------- cd `dirname $0` # change to working directory if [ -e $runfile ]; then # if run with run file present rm $runfile # delete run file killall `basename $0` # stop all instances of this script else # run script if [ ! -e $outdir ]; then # if output directory not found mkdir $outdir # make output directory fi echo "delete this to stop dump" > $runfile # make control file if [ -e $ininame ]; then # if counter ini exists read n dummy < $ininame # set counter else echo $n > $ininame # otherwise reset counter ini fi sleep 10 # initial delay to focus window to dump while [ -e $runfile ]; do outfile="$outdir/$fbase$n$fext" if [ -e $outfile ]; then rm $outfile # remove file if it exists fi wmctrl -Fa $window # focus app window import -window $window $outfile # dump app screen to file if [ "$?" -eq 0 ]; then # if dump was successful n=$[ $n + 1 ] # next file number echo $n > $ininame # update counter ini sleep $interval # wait until next dump time else # app is no longer running, terminate rm $runfile fi done if [ -e $runfile ]; then rm $runfile # remove run file if it exists fi fi