a small collection of personal scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.0KB

  1. weechat::register ("banshee-np", "shmibs", "0.3", "GPL", "banshee-weechat current song script (usage: /np)", "", "");
  2. weechat::hook_command("np", "", "", "", "", "banshee", "");
  3. use Encode;
  4. sub banshee {
  5. my ($data, $buffer, $args) = @_;
  6. my @colours = (13,11,9,4);
  7. my ($name, $title, $album);
  8. # 9 green
  9. # 4 red
  10. # 6 pink
  11. # 13 pink
  12. # 11 blue
  13. # 7 yellow
  14. if(qx/ps -A | grep banshee/ ne ""){
  15. chomp(($name, $title, $album) = (decode_utf8(substr(`banshee --query-title`,7)), decode_utf8(substr(`banshee --query-artist`,8)), decode_utf8(substr(`banshee --query-album`,7))));
  16. } else {
  17. ($name, $title, $album) = "";
  18. }
  19. if($name ne ""){
  20. #~ weechat::command($buffer, "/me is hearing: \N{U+266B} \x{03}$colours[1]$name\x{0f} by \x{03}$colours[2]$title\x{0f} from \x{03}$colours[3]$album\x{0f} \N{U+266B}");
  21. weechat::command($buffer, "/me \N{U+266B} $name by $title from $album \N{U+266B}");
  22. } else {
  23. weechat::command($buffer, "/me is too dumb to use scripts, apparently )=");
  24. }
  25. return weechat::WEECHAT_RC_OK;
  26. }