Guest User

Untitled

a guest
Apr 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use Audio::MPD;
  4.  
  5. weechat::register("nowplaying", "Ricky Elrod", "0.1", "BSD", "NowPlaying Script.", "", "");
  6. weechat::hook_command("np", "Display your currently playing MPD song, if any.", "", "", "", "np", "");
  7.  
  8.  
  9. my $mpd = Audio::MPD->new();
  10.  
  11. sub np {
  12. my ($data, $buffer, $param) = @_;
  13. my $act;
  14. my $state = $mpd->status()->{'state'};
  15. $state = 'stopp' if $state eq 'stop';
  16. my $percent = $mpd->status()->{'time'}->{'time'};
  17. my @psplit = split(/:/,$percent);
  18. my $current = int($psplit[0]);
  19. my $full = int($psplit[1]);
  20. $percent = int(($current/$full)*100);
  21.  
  22. if($state eq "play"){
  23. $act = "is listening to: ".$mpd->current()->{'artist'}." - ".$mpd->current()->{'title'}." [$percent%]";
  24. } else {
  25. $act = "is not listening to anything. (MPD Status: ".$state."ed)";
  26. }
  27. weechat::command($buffer, "/me $act");
  28. }
Add Comment
Please, Sign In to add comment