mengu on web programming.

Rhythmbox support for Konversation

Many of us use Konversation as our primary IRC client and many of us use Rhythmbox as our primary music player. Since Konversation is KDE and Rhythmbox is GTK, Konversation doesn't support Rhythm box for its /media script. Just some moments ago I've added Rhythmbox support on Konversation.

It was easy since the /media is a Python script. It was communicating with command line results of players so I searched how to retrieve information via command line from Rhythmbox and I found there is "rhythmbox-client" which is very helpful.

Anyways, if you want to use this integration, here are the instructions.

  • Open "/usr/share/kde4/apps/konversation/scripts/media" in your text editor as root.
  • Go to line 47 and add "rhythmbox" for "audio" dictionary key.
  • Add the following class around line 430:

    class RhythmboxPlayer(Player):
    def __init__(self):
        Player.__init__(self, 'Rhythmbox', 'audio')
        self.isRunning()
    
    def getData(self):
        if self.isRunning():
            title = os.popen("rhythmbox-client --print-playing-format \"%tt\"").readline().strip()
            artist = os.popen("rhythmbox-client --print-playing-format \"%ta\"").readline().strip()
            album = os.popen("rhythmbox-client --print-playing-format \"%at\"").readline().strip()
            return (title, artist, album)
        else:
            return ""
    
    def isRunning(self):
        self.running = False if os.popen("rhythmbox-client --print-playing").readline().strip() == "Not playing" else True
        return self.running
    
  • Go to line 489 and add "RhythmboxPlayer()," for the "PLAYERS" list.

That's all.

Comments

Mike said on 11/08/2010 10:39 AM

When i type /audio in Konversation, i dont get any errors or notices that this isnt work.

An idea why?


Leave a Response

No HTML allowed. You can use markdown.
Name*:
E-Mail* (not published):
Web site:
Response: