everybodys got one.. heres mine!
#!/usr/bin/perl -w
use XML::Parser;
use HTTP::Date(str2time);
use POSIX;
use LWP::Simple;
# number of lines to be displayed
$numlines = 1;
my $url = shift;
my $data = get($url);
my $parser = new XML::Parser(Handlers =>
{
Start => \&hdl_start,
End => \&hdl_end,
Char => \&hdl_char,
Default => \&dummy
});
my $iprint = 0;
my $pprint = 0;
my $item = 0;
$parser->parse($data);
sub hdl_start
{
my ($p, $lmnt, $attr) = @_;
if($lmnt eq 'item')
{ $item = 1; }
elsif($lmnt eq 'title')
{ $iprint = 1; }
elsif($lmnt eq 'pubDate')
{ $pprint = 1; }
}
sub hdl_end
{
my ($p, $lmnt) = @_;
if($lmnt eq 'item')
{
$item = 0;
$numlines--;
}
elsif($lmnt eq 'title')
{ $iprint = 0; }
elsif($lmnt eq 'pubDate')
{ $pprint = 0; }
}
sub hdl_char
{
my ($p, $str) = @_;
return unless $item gt 0 && $numlines gt 0;
if($iprint gt 0)
{ print $str."\n"; }
if($pprint gt 0)
{ print "\ton ".tolocaltime($str)."\n"; }
}
sub dummy { }
sub tolocaltime
{
my $str = shift;
my $buf = localtime(str2time($str));
$buf = str2time($buf, strftime("%z", localtime));
return localtime($buf);
}
conkyrss.pl (1.3 KiB, 373 downloads)
to use it add the following line to your .conkyrc
${execi <update-interval-in-sec> /path/to/conkyrss.pl "http://url.to.rss/feed"}
// sluggo


