Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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");
- }
Add Comment
Please, Sign In to add comment