#!/usr/bin/perl -s
use XML::DT;
use strict;
our ($s,$w,$i,$d,$noi,$h,$quiet,$n,$noactas,$v);
my $scale=($n ? "" : "scale=0.93,");
my ($s1,$s2);
$s1 ||= "laser.wav" if -f "laser.wav";
$s1 ||= "/usr/local/lib/mklf/laser.wav" if -f "/usr/local/lib/mklf/laser.wav";
$s2 ||= "gong.wav" if -f "gong.wav";
$s2 ||= "/usr/local/lib/mklf/gong.wav" if -f "/usr/local/lib/mklf/gong.wav";
usage() if $h;
my $xml=shift or usage();
my @a =() ; #= ();
if($v){
dt($xml,(p=>sub{ warn("$v{ref} not found\n") unless -f $v{ref} }));
exit 0;
}
if($noactas) { open(TEX, ">/dev/null") or die;}
else { open(TEX, ">$xml.actas.tex") or die;}
starttex();
pathdt($xml, (
# 'author' => sub{ },
'dur' => sub{ $d ||= $c },
'noquest' => sub{ $noi = 1; },
'p' => sub{
print TEX '\includepdf[',
$scale,
'frame,nup=1x2,pages=-,delta=0.5cm 0.5cm]{',
$v{ref},"}\n";
push(@a,$v{ref}) },
'head/title' => sub{
print TEX '\title{', $c, '} \maketitle \tableofcontents ',"\n" },
'p/author' => sub{
print TEX '\addcontentsline{toc}{subsection}{', $c, '}',"\n" },
'p/title' => sub{
print TEX '\addcontentsline{toc}{section}{', $c, '}',"\n" },
));
endtex();
close(TEX);
$s ||=0;
use Proc::Simple;
my $p;
my $com = { pdf => "xpdf -fullscreen -remote batata ",
pps => "ooimpress -show ",
ppt => "ooimpress -show ",
odp => "ooimpress -show ",
};
my $conf ={ dur => $d*60 || 5*60 ,
intervalo => $i*60 || 3*60 ,
sound => 1};
$conf->{intervalo} = 0 if $noi;
$conf->{warning} ||= $w*60 || int(0.8 * $conf->{dur});
print "'$d' $conf->{dur}\n";
my $a1;
for(2 .. $s){shift(@a)}; # start in presentation number $s
sleep 3; # to change window
for $a1 (@a) {
presentation($conf,$a1); # start presentation ai
if( $conf->{intervalo}){ intervalo($conf) } # intervalo is a single-slide
else { sleep 2} # intervalo = 2s
}
$p->kill() if $p && $p->poll(); # ensure the proc was killed
sub intervalo{
my %opt = ( dur => 60 );
if(ref($_[0]) eq "HASH") {%opt = (%opt , %{shift(@_)}) } ;
presentation({dur=> $opt{intervalo}},"q.pdf");
}
sub presentation{
my %opt = ( dur => 5*60 ); #default duration = 5 min
my $optg;
if(ref($_[0]) eq "HASH") {%opt = (%opt , %{$optg= shift(@_)}) } ;
my $a2 = shift or die;
my $ext=$a2;
$ext =~ s/.*\.//;
warn("Dont know the $ext format\n") unless defined $com->{$ext};
if($p and $p->poll()){
system("$com->{$ext} $a2 &");
}
else {
undef $p;
$p = Proc::Simple->new();
$p->start("$com->{$ext} $a2");
}
for(1 .. $opt{dur}){
if($p && $p->poll()) { sleep(1); }
if($_ eq $opt{warning}) { system("play $s1 2>/dev/null &");}
if($_ eq $opt{dur} - 2) {
if ($quiet){
system("play $s1 2>/dev/null &");
system("play $s1 2>/dev/null &");
}
else { system("play $s2 2>/dev/null &");}
}
if(!$p or !$p->poll()) {
last }
}
$p->kill() if $p && $p->poll();
undef $p;
}
sub usage{
die qq{Usage: $0 options presentation.xml
where options are:
-s=3 start in presentation 3
-i=3 Questions? (time in minutes) def: 3m
-noi No interval for questions
-d=3 Duration of the presentation (time in minutes) def: 5m
-w=4 Warning at 4minutes (def: 80% of duration)
perldoc $0 for more informations
};
}
sub starttex{
print TEX '
\documentclass[portuges,a4paper]{article}
%\RequirePackage[papersize={18cm,28cm},top=2cm,left=2cm,right=2cm,bottom=1.5cm,nohead,nofoot]{geometry}
\RequirePackage[a4paper,top=2cm,left=2cm,right=2cm,bottom=1.5cm,nohead,nofoot]{geometry}
\usepackage{babel}
\usepackage[latin1]{inputenc}
%\usepackage[utf8]{inputenc}
\usepackage{t1enc}
\usepackage{pdfpages}
\usepackage{fancyvrb}
\begin{document}
%\fvset{fontsize=\small, frame=single, numberblanklines=false}
\fvset{fontsize=\small, frame=leftline, numberblanklines=false}
';
}
sub endtex{
print TEX '
\end{document}
';
}
__END__
=head1 NAME
mklf - lightening talks animaters
=head1 SYNOPSIS
mklf [options] presentation.xml
options are:
-s=3 start in presentation 3
-i=3 Questions? (time in minutes) def: 3m
-noi No interval for questions
-d=3 Duration of the presentation (time in minutes) def: 5m
-w=4 Warning at 4minutes (def: 80% of duration)
-h This help
-quiet Instead of a noisy GONG, plays two LASER
-n In the proceedings - don't scale the slides
-noactas Dont make proceedings
-v See if all the PDF presentations exists and exit
=head1 DESCRIPTION
Generates a LaTeX file (g.actas.tex) -- with the proceedings
Starts the lightening presentations specified in the presentation.xml file.
At 80% of the time, the system sounds a laser sound.
At 100% of the time (5min by dafault), the system sounds a GONG!, waits
3s and starts the next presentation.
In order to have full PDF proceedings, presentations should be in PDF.
The luscofusco sistem also accepts PPT, PPS (Powerpoint) and ODP formats,
but no proceedings (yet).
=head2 Format of presentations: examples
In the most simple form: