#!/usr/local/bin/perl -w
###########################################
# pounce-yml-to-xml
# Mike Schilli, 2008 (m@perlmeister.com)
###########################################
use strict;
use Sysadm::Install qw(:all);
use YAML qw(LoadFile);
use Template;
my($home) = glob "~";
my $path = "$home/.pidgin-pounce";
my $yaml = LoadFile( "$path/pounce.yml" );
my $xml_file = "$home/.purple/pounces.xml";
my $SOUND_CMD = "~/bin/pounce-sound";
my @pounces = ();
for my $account (
keys %{ $yaml->{sound_map} }) {
my($proto, $recv) = split /:/, $account;
for my $buddy (keys %{
$yaml->{sound_map}->{$account} }) {
push @pounces,
mk_pounce($buddy, $recv, $proto);
}
}
binmode STDOUT, ":utf8";
my $xml = q{
[% FOR pounce IN pounces %]
[% pounce %]
[% END %]
};
my $tmpl = Template->new();
mv $xml_file, "$xml_file.old" if
-f $xml_file;
$tmpl->process( \$xml,
{ pounces => \@pounces },
$xml_file ) or die $tmpl->error;
###########################################
sub mk_pounce {
###########################################
my($buddy, $recv, $prot) = @_;
return qq{
$recv
$buddy
$SOUND_CMD $prot:$recv $buddy
}
}