KDE Tricks – Using DCOP to communicate with AmaroK

29 01 2006

Sort of following up on my conversion to Kubuntu and the following of the KDE Way, I learned a couple tricks about KDE this week.
I had been using XMMS as my music player forever and a day. Since I like chattering about what music I’m listening to when I’m on IRC, I wrote a little macro into X-Chat that let me say on channel (or in a msg) what XMMS was currently playing. To do this I used xmms-shell, a command line utility for interacting with XMMS. But since I converted to AmaroK, that obviously wouldn’t work anymore.
I started looking around for something similar to xmms-shell for AmaroK, when a fellow on #kde-users suggested looking at the ‘dcop’ command line tool. I had very little exposure to dcop – I knew it was one of the technologies underlying KDE, but I wasn’t sure exactly what it was.
DCOP, according to the wikipedia page on it, stands for ” Desktop COmmunication Protocol”, and is a light-weight interprocess and software componentry communication system. What this means for the layman is that virtually any application built for KDE has a series of methods and properties exposed for access from a dcop client. KDE provides the command line tool ‘dcop’ and a GUI desktop tool called, unsurprisingly, ‘kdcop’ for exploring and using these interfaces. I used kdcop to browse through the AmaroK DCOP remote methods, and found ‘nowPlaying()’. It was a simple matter of putting this into an x-chat macro:

/exec -o echo `dcop amarok player 'nowPlaying()'`

Binding that to the ‘x’ key in x-chat, now at any point I can just type /x and whatever track I’m listening to shows up in the channel or msg window I’m in.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: