MacHackin’
November 19th, 2008
Well, I have been working and living with a MacBook Pro for a few weeks now and I have to say I’m liking it a lot more than I had thought I would. I am starting to get the hang of how everything works and I am very happy about just how similar things are to LINUX when you open up the command line. I had heard that, despite being built on BSD, much of that functionality was crippled in some way in OSX. Thankfully, that is not the case at all.
I finally got a chance this week to take a crack at customizing things a little bit. I have been listening to Internet Radio .977 lately, a set of “radio” channels I found in my ShoutCast playlist in XBMC. One thing that is very cool about working on a Mac is that so many of the applications play really well together. For instance, if you are listening to music in iTunes, with a couple of clicks you can have the current song showing up in your status in iChat or Adium. Unfortunately for me, the .977 stream does not play in iTunes. I listen to it in VLC, which does not fit together with the chat apps the way iTunes does.
I did a little Googling and wasn’t able to find much on the subject. There are a few ways to get current media information out of VLC, however, most of that is geared towards playing mp3s and using these techniques I was only able to extract the name of the radio station I was listening to, not the track name that was appearing in the VLC window. Additionally, I was able to find a site that detailed writing some Applescript and BASH scripts to set iChat/Adium status to dynamically indicate your location, based on IP address. After a little tinkering I was able to put something together.
I won’t bother with all of the details here (anyone who wants to know how it was done, drop me a line). Basically my solution was this: setup VLC to write its log out to a file and set the verbosity of the logging to max. When the track playing changes a line is written to the log including “New Title=XXX” where XXX is the track listing as it appears in the main VLC window. This information was utilized with two BASH scripts (one to pull the last song entry from the log and parse the song from that line and another to control this whole process) and one Applescript to push the status into the chat apps. A little cron magic and it works like a charm!

