#!/usr/bin/perl

$sDuration = "600.0"; # таймаут между сменой фотографий в секундах
$tDuration = "20.0"; # плавность смены в секундах

print <<"TBEGIN";
<background>
  <starttime>
    <year>2009</year>
    <month>08</month>
    <day>04</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
TBEGIN

$pwd = `pwd`;
$pwd =~ s/[\n]//;
$isStart = 0;
opendir(DIR,".");
while ($name = readdir(DIR)) {
if($name =~ /jpg|png/){
    if($isStart){
            $pathLast = $pwd."/".$lastName;
            $pathCurr = $pwd."/".$name;
            print <<"Tname";
<static>
  <duration>$sDuration</duration>
    <file>$pathLast</file>
  </static>
  <transition>
    <duration>$tDuration</duration>
    <from>$pathLast</from>
    <to>$pathCurr</to>
</transition>
Tname
    } else {
        $pathFirst = $pwd."/".$name;
    }
    $lastName = $name;
    $isStart = 1;
}
}
closedir(DIR);

print <<"TEND"
<static>
  <duration>$sDuration</duration>
    <file>$pathCurr</file>
  </static>
  <transition>
    <duration>$tDuration</duration>
    <from>$pathCurr</from>
    <to>$pathFirst</to>
</transition>
</background>
TEND