[Xastir] Saving serial snapshots

Curt, WE7U archer at eskimo.com
Wed Apr 15 21:55:12 EDT 2009


On Thu, 16 Apr 2009, Carl Makin wrote:

> Something like;
>
> #!/bin/sh
>
> RIGHTNOW=`date +%Y%M%d%H%M`
>
> if [ -f 'snapshot.jpg' ]; then
>        mv snapshot.jpg archive/snapshot-$RIGHTNOW.jpg
> fi

Ready for my version?  It's a bit bigger but there's really not a
lot of code:

---------------------------------------------------------------------
#!/usr/bin/perl

#
# Copies/renames ~/.xastir/tmp/snapshot.png files so that a
# slideshow can be created from the images at a later date.  The
# script monitors the directory.  Any new snapshot.png file that
# appears is allowed to age for a few seconds to make sure that
# Xastir is done writing the file, then the file is copied to the
# ~/.xastir/tmp/slideshow/ directory as a numbered file.
#

$input_dir = "/home/archer/.xastir/tmp";
$output_dir = "$input_dir/slideshow";

mkdir "$output_dir";
chdir ($input_dir);

while (1) {
   $current_time = time;

   # Snag the age of the existing snapshot.png file
   $number = (stat("snapshot.png"))[9];

   $difference = $current_time - $number;

   # If the age of the file is more than 15 seconds but less than 30
   # minutes, copy the file to the slideshow directory and rename it
   # along the way.
   #
   if ( ($difference > 15) && ($difference < (30 * 60)) ) {

     # Copy the snapshot image to the slideshow directory, renaming
     # it with the Unix Epoch time.
     `cp snapshot.png $output_dir/$number.png`;
   }
   sleep 30;
}
---------------------------------------------------------------------

-- 
Curt, WE7U.				archer at eskimo dot com
http://www.eskimo.com/~archer
   Lotto:  A tax on people who are bad at math. - unknown
Windows:  Microsoft's tax on computer illiterates. - WE7U.
The world DOES revolve around me:  I picked the coordinate system!"



More information about the Xastir mailing list