rendered paste body#!/usr/bin/perl
use vars qw($VERSION %IRSSI);
use Irssi;
use strict;
%IRSSI = (
name => 'amaroknp',
);
my $tool = "qdbus org.kde.amarok /Player GetMetadata";
sub cmd_amarok {
my ($data, $server, $witem) = @_;
my $title, my $album, my $artist;
my $output;
my $amarokinfo = `$tool`;
# if amaroK is running, let's get teh infos!
if($amarokinfo ne "") {
# $amarokinfo =~ s/\n//g;
$amarokinfo =~ m/album: (.+)\n/;
$album = $1;
$amarokinfo =~ m/artist: (.+)\n/;
$artist = $1;
$amarokinfo =~ m/title: (.+)\n/;
$title = $1;
$output ="> $album: $artist - $title";
if ($output) {
if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {
$witem->command("ACTION ".$witem->{name}." $output ".shift);
}
else {
Irssi::print("This is not a channel/query window :b");
}
}
}
else {
print "amarok isn't playing anything =I";
}
}
Irssi::command_bind('amarok', 'cmd_amarok');