Created
November 15, 2009 03:39
-
-
Save relrod/234960 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Audio::MPD; | |
weechat::register("nowplaying", "Ricky Elrod", "0.1", "BSD", "NowPlaying Script.", "", ""); | |
weechat::hook_command("np", "Display your currently playing MPD song, if any.", "", "", "", "np", ""); | |
my $mpd = Audio::MPD->new(); | |
sub np { | |
my ($data, $buffer, $param) = @_; | |
my $act; | |
my $state = $mpd->status()->{'state'}; | |
$state = 'stopp' if $state eq 'stop'; | |
my $percent = $mpd->status()->{'time'}->{'time'}; | |
my @psplit = split(/:/,$percent); | |
my $current = int($psplit[0]); | |
my $full = int($psplit[1]); | |
$percent = int(($current/$full)*100); | |
if($state eq "play"){ | |
$act = "is listening to: ".$mpd->current()->{'artist'}." - ".$mpd->current()->{'title'}." [$percent%]"; | |
} else { | |
$act = "is not listening to anything. (MPD Status: ".$state."ed)"; | |
} | |
weechat::command($buffer, "/me $act"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment