Amarok now playing... to remote irssi.
Posted by Eric Stein - July 26, 2007 CE @ 19:10:27 UTC
I've got frustrated typing out now playing information in irssi when I'm using my laptop. Today I fixed the problem.
On the laptop:
On the server side, the script is very simple - all it has to do is cat the file into the current irc channel:
On the laptop:
#!/usr/bin/php
<?php
while (true) {
system('echo "playing: `dcop amarok player artist` [`dcop amarok player album`] - `dcop amarok player title`"|ssh toba.ath.cx "cat > priv/playing.txt"');
echo "sent info...\n";
$c = array();
$t = array();
exec('dcop amarok player totalTime', $t);
exec('dcop amarok player currentTime', $c);
$c = explode(':', $c[0]);
$t = explode(':', $t[0]);
$w = intval($t[0]) * 60 + intval($t[1]) - intval($c[0]) * 60 - intval($c[1]) + 1;
echo "waiting " . $w . " seconds...\n";
sleep($w);
}
?>
How it works: get current playing information from Amarok, and write this to a file on my server. Ask Amarok how long the track is going to play for, wait until the next track will have just started. Rinse, repeat.<?php
while (true) {
system('echo "playing: `dcop amarok player artist` [`dcop amarok player album`] - `dcop amarok player title`"|ssh toba.ath.cx "cat > priv/playing.txt"');
echo "sent info...\n";
$c = array();
$t = array();
exec('dcop amarok player totalTime', $t);
exec('dcop amarok player currentTime', $c);
$c = explode(':', $c[0]);
$t = explode(':', $t[0]);
$w = intval($t[0]) * 60 + intval($t[1]) - intval($c[0]) * 60 - intval($c[1]) + 1;
echo "waiting " . $w . " seconds...\n";
sleep($w);
}
?>
On the server side, the script is very simple - all it has to do is cat the file into the current irc channel:
/alias m exec -o cat priv/playing.txt
It works like a charm:[15:10:06] <@Toba|BSD> playing: Duran Duran [Greatest] - Is There Something I Should Know?
Post a Comment