One of the first things that actually triggered my interest in Spotify was that although they did not have an official Linux client, they did seem to try and assure it worked well in Wine, even recommending using Wine to Linux users, with this page dedicated to assuring the experience is complete as possible (although it generally works out the box).

One of the most useful parts of that page is where they provide a nice, simple script to allow native Linux applications to call the Spotify client running under Wine with Spotify’s URIs that are used to share playlists, tracks, etc. They also provide instructions on how to get Firefox and Opera to call this script for those URIs (for example using an entry on about:config in Firefox).

This works great, until you try to use the URIs outside Firefox or Opera, say in Pidgin or a Chromium alpha, neither of which appear to provide their own methods for supporting custom URIs, instead they depend on either Gnome or ‘xdg-open’ (which in turn can ask Gnome). So I thought it might be a good idea simply to tell Gnome to use the script, and let everything else depend on Gnome; sadly I could find no graphical way of doing this, but after a bit of searching, I found this page, which revealed it was a simple as adding a few keys to GConf. So I adapted to method for the Spotify URI and script, and sure enough it works fine (certainly in both Chromium and Pidgin, on Ubuntu 9.04).

Below are the normal commands need to create aforementioned script:

echo '#!/bin/sh' > ~/.browser2spotify
echo 'exec wine "C:\Program Files\Spotify\spotify.exe" /uri "$@"' >> ~/.browser2spotify
chmod 755 ~/.browser2spotify

And here are the commands for adding the GConf keys, but be careful, tidles and variables didn’t appear to work here, so you will need to manually modify the address in the first command to reflect your username:

gconftool-2 -t string -s /desktop/gnome/url-handlers/spotify/command "/home/<your username here>/.browser2spotify %s"
gconftool-2 -s /desktop/gnome/url-handlers/spotify/needs_terminal false -t bool
gconftool-2 -s /desktop/gnome/url-handlers/spotify/enabled true -t bool

Fingers crossed, all applications that call on Gnome or ‘xdg-open’ for unknown URIs (such as the aforementioned Pidgin and Chromium), should now be able to call Spotify; in fact, Firefox too calls either Gnome or ‘xdg-open’, so this method can suffice for Firefox too.

Chromium alpha calling Spotify via 'xdg-open'

Chromium alpha calling Spotify via 'xdg-open'

Tags: , , , , , , , , , , ,

This entry was posted on Wednesday, September 9th, 2009 at 9:50 pm and is filed under Linux, Ubuntu, Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 comments so far

Speed
 1 

It worked like a charm. Thanks so much :)

September 23rd, 2009 at 12:30 pm
spotify:track:0m5Rq45gzAfKwEBYlljVZ1
 2 

Hey bro! Your solution works just great!

What about links like “spotify:track:0m5Rq45gzAfKwEBYlljVZ1″ in Chromium??

Do you have any ideas?

Cheers!

September 30th, 2009 at 1:26 am
Rob Parker
 3 

Thanks, good to see it actually is, anyways – well If I look at a site with track URI, say exactly the one you quote – such as http://spotify.url.fi/track/0m5Rq45gzAfKwEBYlljVZ1 – I can click the link and it does cause Chromium to ask whether I want to open it in Spotify, which works just like with the playlist URIs.

Hope that helps.

October 9th, 2009 at 4:29 pm

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment