Let XMMS talk to Jabber

I had this idea a couple days ago. I use a Jabber client to talk to Tracy, co-workers, etc while I'm at the PC (as Jabber is simply a protocol, there are many of clients; the one I use is called Konverse). I also frequently listen to music in MP3 format, typically streaming from my home PC to a Linux MP3 player called XMMS. I dot his when I'm at home, and when I'm at work.

Well, to make a long story short Jabber supports this notion of a "presence". You can be merely "Away", or you can be "Extended Away", or "Normal" or "Do Not Disturb". Like when you are going to lunch, you can set your presence to "Away" and then even put in a little bit of text to explain where you are going to go eat. When you are going to a two hour meeting, you'd select "Extended Away" and then enter something like "Another goddam meeting to go to" as your text. You get the idea.

A couple things about this handy presence thing have occurred to me:

  1. I sometimes set my presence so that other know where I am, but I forget to more often than not and I rarely enter any explanatory text for my presence whereabouts
  2. When I'm leaving my desk I almost always either pause XMMS, stop the currently playing selection, or quit the app altogether depending on how long I'm going to be away
Starting to see a connection here? Me too.

It turns out that XMMS has a number of handy features, two of which are of interest to me. First, it has a very nice set of keyboard shortcuts. You can almost do more by using keyboard accelerator keys than you can by clicking things with the mouse. I use shortcut keys a lot (like ctrl_tab to go between desktops, alt+tab to go between windows, etc). So I find myself using alt-tab to go to XMMS, then using one of these keys:
    z = Previous Song
    x = Play
    c = Pause
    v = Stop
    b = Next Song
And then typically I lock my screen. Very handy.

The second thing about XMMS that concerns me lately is that it has an API. Meaning you can write applications that talk to it. Or get info from it. And since I can write applications and can read XMMS's API spec, I can talk to XMMS. Or get info from it. Even via Perl.

I said earlier that Jabber was merely a protocol (as in a "messaging protocol"), not an application (as in AIM, ICQ, etc). Lots of people have written apps that use the Jabber protocol. Some people have even written Perl modules that can talk to Jabber servers.

So I always forget to set my presence (causing people to repeatedly type "Hello, are you there?" and whatnot on Saturday when I'm not anywhere near the office PC that Konverse is running on, or when I'm at lunch) yet I almost never forget to dim the music. I can get info from XMMS and find out what is playing, whether it's paused, stopped, or even if the app isn't running. I can write a small process that sends Jabber information, specifically presences. Then this all means that all I have to do is write a small app which runs in the background, detects when I'm logged in, polls XMMS and sets my presence appropriately.

I'm thinking that if I'm playing music, I'm "Normal" (ie, able to talk). And why not have my presence info be the song title or something frivolous (I get the song title, playlist order and number, encoding rate, and lots of other info as a by-product of finding out the state of XMMS and I have to send something when I set a presence -- so it's not like it's extra work to send the title as the presence text)? When the music is paused, then I'm just "Away". Maybe set the presence text to "Music's paused, Bill's away for a bit..." When I've stopped the music, I'm "Extended Away". Presence says like "Music ain't playing, he ain't there." If I've quit XMMS, then I'm "Do Not Disturb" and the presence is "It's quiet time."

The only wrinkle is that I don't know how I would go about listening to music when I also don't want to be disturbed (like maybe it's a Miles Davis kind of day). I suppose I could simply shut down Konverse. Or I could use my app as a small wrapper script which I could pass messages to. Either way, the whole thing is frivolous, but that never stopped me before.

Comments for: Let XMMS talk to Jabber

Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?