How to: Spotify and xdg-open

I had some trouble with Spotify URIs on Google Chrome, seeing as it uses xdg-open for everything external (not a bad thing) and I could not use about:config as with Firefox. After some googling and asking around I found this to work:

Note that I’m running GNOME, so this guide covers the use of gnome-open. If you use KDE, Xfce or any other desktop environment, and you know how to add support for other URIs on that version of xdg-open, feel free to comment.

First, we need a bash script to run Spotify. This one assumes that you’ve installed Spotify with PlayOnLinux:

#!/bin/bash
cd "$HOME/.PlayOnLinux/wineprefix/Spotify/drive_c/Program Files/Spotify"
WINEPREFIX=$HOME/.PlayOnLinux/wineprefix/Spotify/ wine spotify.exe /uri $1

Save this and make it executable with chmod +x.

Now, let’s tell GConf that we have a URI handler for spotify.

gconftool-2 -t string -s /desktop/gnome/url-handlers/spotify/command "location of the bash script %s"
gconftool-2 -t bool -s /desktop/gnome/url-handlers/spotify/needs_terminal false
gconftool-2 -t bool -s /desktop/gnome/url-handlers/spotify/enabled true

After that, you’re done! Enjoy launching Spotify directly from Chrome/xdg-open!

Thanks to:

3 Comments »

  1. watch for the typo on the last gconftool-2 command, it should read:

    gconftool-2 -t bool -s /desktop/gnome/url-handlers/spotify/enabled true

    Comment by Ben — October 7th, 2009

  2. Thanks, I was wondering why it didn’t work on my other computer..

    Comment by TheLinx — October 11th, 2009

  3. I was so very glad if anyone would found a solution to do that in kde.

    Comment by Bausparfuchs — March 10th, 2010

Leave a comment