Guest User

Untitled

a guest
Feb 20th, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # ==============================================================================
  2. # amarok.rb (c) July 2006 by Michael 'manveru' Fellinger <manveru@weez-int.com>
  3. #
  4. # Licence: GPL v2
  5. # Description: Display what Amarok is playing right now in the current channel
  6. # Syntax: /np
  7. #
  8. # ==============================================================================
  9.  
  10. def weechat_init
  11. Weechat.register("amarok", "0.1", "", "display what Amarok is playing right now in the current channel (/np)")
  12. Weechat.add_command_handler("np", "amarok")
  13.  
  14. return Weechat::PLUGIN_RC_OK
  15. end
  16.  
  17. def amarok(server, args)
  18. # this maps directly to dcop-calls
  19. # options:
  20. # %album %artist %bitrate %comment %coverImage %currentTime %encodedURL
  21. # %engine %genre %lyrics %nowPlaying %path %title %totalTime %track %type %year
  22. # %% => %
  23.  
  24. user = `whoami`.chomp
  25.  
  26. unless `dcop --user #{user} amarok`.chomp == "ERROR: Couldn't attach to DCOP server!"
  27. format = %(%artist (%album) - %title [%totalTime])
  28. format.gsub!(/%([A-Za-z]+)/){|e| `dcop --user #{user} amarok player #{$1}`.chomp}
  29. format.gsub!('%%', '%')
  30.  
  31. Weechat.command(format)
  32. end
  33.  
  34. return Weechat::PLUGIN_RC_OK
  35. end
Add Comment
Please, Sign In to add comment