Extracting a Radio Station URL from Banshee 2 SQLite DB

I’ve wanted for a while to extract a radio station url for HBR1, Ambient from Banshee 2.0.1.

My first thought was to grep recursively and disregarding character case for ‘hbr’ in $HOME. That didn’t work.

After some time I realized that probably Banshee stored most of the data in a sqlite db. I was right about that, but  finding the radio station url still wasn’t as simple.

Here’s what I did to get it printed out on my console:

~/.config/banshee-1 % sqlite3 banshee.db ‘select * from CoreTracks’ | grep -i hbr
3|2586|12|463|0|0||http://ubuntu.hbr1.com:19800/ambient.ogg||0|0|0|0|5|0|HBR1, Ambient|hbr1 ambient||,    �
!/Q    2!p�|0|0|0|0|0|0|Ambient|||||||0|0|0|0|||1294327820|1326656231|d6bb2e3f688f3bb51bbf660a6707629e|0||0
3|2587|12|464|0|0||http://ubuntu.hbr1.com:19800/tronic.ogg||0|0|0|0|5|1|HBR1, House|hbr1 house||,    �
!/,|��!|0|0|0|0|0|0|House|||||||0|0|0|0|||1294327883|1320570155|0d8fca4c8853d6f5da29987a912f0ea6|0||0
3|2588|12|465|0|0||http://ubuntu.hbr1.com:19800/trance.ogg||0|0|0|0|5|0|HBR1.com – I.D.M. Tranceponder|hbr1com – idm tranceponder||,    �
!3

Yeah, not pretty, but who cares as long as you can extract your data, right? Of course, if you’re going to re-use the output in your scripts you’ll have to figure out how to make the output prettier. If you do that, drop me a line in the comments section, please.

Ordering the GNOME systray

I love exactly this sequence of icons in my GNOME systray

See those icons in the systray? While plenty of people do not care in what order those icons are placed in their systray I do. And this topic has been on my mind for some time since the realization of how great control over the system and its components can be in a Linux environment dawned on me.

My first try was with KDE 3.5.x and it was a no go. I came up with this idea of running a simple bash script, essentially an ordered sequence of applications I always need to run upon the new login session, but it wouldn’t work as expected. For some reason sleep command was ignored and to put applications in a specific order it was basically impossible. I think it could be due to poor idea implementation but since I moved away from KDE and use GNOME these days it doesn’t matter anymore.

Here I am working in GNOME and after having to run 7-8 applications each time I start up the laptop or login anew, which in itself takes up about 5-7 minutes and requires human attendance, this quickly became a real pain. 2011, advanced computing technology is abundant, automation is thriving as never before and here I am spending about an hour a week or so doing what, running 7-8 applications – a pointless, dumb activity.

So, I decided to try it again and this time I got it done right. GNOME simply follows the logic that I use when think about how GNOME could handle autostart applications, such as a bash script, which eventually enables me to run:

  1. pidgin
  2. stardict
  3. zim
  4. transmission
  5. banshee
  6. miro
  7. evolution

in exactly that sequence automatically.

Here’s how it’s done.  I created a bash script ~/scripts/autostart.sh, gave it execution bit by chmod +x. Its contents is outrageously simple:

#!/bin/sh
stardict &
sleep 25
zim &
sleep 1
transmission-gtk &
sleep 3
banshee-1 –redirect-log –play-enqueued %U &
sleep 5
miro &
evolution &

sleep parameter is needed to introduce pauses in between the execution of applications (so that they’re not run and placed in systray haphazardly) and tuned to account for time required to start an application. In my case stardict takes quite a bit of time to start due to a big number of dictionaries needed to be loaded so it’s 25 seconds. It’ll all depend on your very own set of applications and how fast they load. Conduct an observation session and note down the results, then use them as parameters for your script.

When your script is ready go to System->Preferences->Startup Applications and add new program, your script.

Startup Applications

Adding new program, my autostart script

Log out and log in to see how it works. I had to log out and in a few times to get the timing right and now I have GNOME running these 7 applications for me, in exact sequence as I defined and placing their icons in systray the way I want them to be placed.

Which is awesome.