rendered paste body#!/usr/bin/perl
use Irssi qw(active_win command_bind);
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0.0";
%IRSSI = (
authors => "Chris MacDonald",
contact => "macdonalder\@rogers.com",
name => "mpd_np",
description => "\'Now Playing\' script for MPD. Requires MPC.",
license => "GPL"
);
Irssi::print("*****\n* MPD Now Playing Script\n*****");
sub cmd_mpd_np {
my ($track, $time);
$track = readpipe('mpc --format \'[%artist% - %title%]\' | head -n 1 | sed \'s/ - $//;s/^ - //\'');
$track =~ s/\n//;
$time = readpipe('mpc | grep playing | tr \' \' \'\012\' | grep :');
$time =~ s/\n//;
active_win->command('say np: '.$track.' - '.$time);
}
command_bind('np', 'cmd_mpd_np');