#!/usr/bin/perl
# amarok announce script for Konversation
# 
# Copyright 2006, Adrian Neumaier <adrian@firehand.org
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.

use strict;

my $port=shift;
my $server=shift;
my $target=shift;

isPlaying();

sub isPlaying{
	my $artist = `dcop amarok player artist`;
	chomp($artist);
	my $title = `dcop amarok player title`;
	chomp($title);
	my $curtime = `dcop amarok player currentTime`;
	chomp($curtime);
	my $totaltime = `dcop amarok player totalTime`;
	chomp($totaltime);

	utf8::decode($artist);
	utf8::decode($title);
	
	my $output = "/me is listening to: %B".$artist."%B - %B".$title."%B (".$curtime."/".$totaltime.")";
	exec 'dcop', $port, 'Konversation', 'say', $server, $target, $output;
}