ralphm.net

ralphm's blog

Thursday, 22 July 2004

Tune

Are you seeing what I'm hearing?

Prompted by online onlineIntosi's questions about using Bonobo for getting information out of Rhythmbox, I got curious myself.

Intosi didn't get his Python script to talk to Rhythmbox, where it did for me. He was intending to make a little User Tune client himself with it. I was able to connect to Rhythmbox and ask for its properties, like song information and whether is was playing or not. However, that was polling, and since pubsub is hot and polling is not, I wanted to be notified by Rhythmbox when its status changed. Well, fortunately Rhythmbox also has an Bonobo event source to which you can assign handlers, and the Rhythmbox source had a test program in C to use this facility.

The C function for this is called bonobo_event_source_client_add_listener(), and appeared to have a Python binding, too. I didn't get it to work, though. It complained about having too many keyword arguments. It turned out that the binding code was incorrect, and the nice guys from the #pygtk IRC room promptly fixed the code in CVS.

Following offline offlinestpeter's mantra #2, I went ahead and implemented Tune. Tune is a little tool that watches Rhythmbox and publishes information about the currently playing song to a pubsub node, using the User Tune protocol as defined in JEP-0118.

The first part was easy. If you have a running Rhythmbox and then start Tune, it nicely watches Rhythmbox and publishes away. The problem comes when there is no Rhythmbox when starting Tune, or when Rhythmbox is exited and possibly started again. I wanted to be able to detect when Rhythmbox was running or not and the #pygtk folks told be how to use the Bonobo Activation Framework to do that. While you can watch register and unregister events, those events don't give information about what got registered, so you have to find out yourself. This is a point of improvement, I'd say.

Tune is a nice proof of concept, and I also set up a Tune monitor for ralphm.net to show the Tune information in the Jabber Fish Tank and on the Jabber World Map. For the future, I'd like to see such publishers integrated into Jabber clients. Maybe a Jabber desktop daemon, to which local applets can talk, would be nice for this as well.

If you want to try out Tune, and have your tune information shown on ralphm.net, let me know.