Getting Spotify’s links to work in Linux is pretty simple. At the time of writing this, there is no native Linux Spotify client available, and these instructions assume you are using the Windows version of Spotify via Wine.
If you are unsure as to what Spotify is exactly, stop right there and read what I have written about Spotify.
These instructions refer to getting ‘spotify://’ links to function, as expected, within Firefox. To do, this we will create a basic script to launch Spotify via Wine and then we will modify Firefox settings in order to make it correctly handle the Spotify protocol.
- First, create a new file in your home directory, calling it ‘spotify.sh’ or a name of equal meaning.
- Paste the following code in to this file. This code launches Spotify (providing it is installed in the default directory) via Wine, and passes through the first argument, in this case, the spotify URL data.
#!/bin/bash
wine “$HOME/.wine/drive_c/Program Files/Spotify/spotify.exe” /uri “$1″ - Make the newly created script executable (i.e. give it the executable permission), which can be done using the following command or if using a file manager such as Nautilus, via the Properties window.
chmod +x spotify.sh
- Add the following two values to Firefox. This can be done be opening Firefox and typing ‘about:config’ into the address bar, clicking past the warning message if necessary, and right clicking the central area and choosing ‘new’ from the pop-up menu then choosing the type of value you wish to create.
Type: string
Name: network.protocol-handler.app.spotify
Value: /home/username/spotify.sh
(Replace ‘username’ in the value above with the username you use to login to your Linux system)
Type: boolean
Name: network.protocol-handler.external.spotify
Value: true
After following these instructions, you should be able to click ‘spotify://’ links within Firefox, and have Spotify open (within Wine) to the relevant track, album, artist or playlist. Enjoy and feel free to use the comments sections below!
If you liked this post, you may be interested in these:
- Spotify – What exactly is Spotify? A fantastic steaming music service, that’s what.
- Wine – Wine is not an emulator – it is a Windows compatibility layer
- Spotify – Spotify gets an offline mode, so your music can play even when offline
- How to SSH Tunnel with the Linux Command Line
- Linux – A simple explanation of Linux and Linux-based operating systems











Can you expand on step 3 please? Where do you type that code? In the terminal window?
@Stu
Hi Stu. You’re very right. For step three, you can open a new terminal, which should open to your home folder by default. Enter the command ‘chmod +x spotify.sh’ into the terminal to make the script executable.
If you wish, you can change the permissions of the script by right-clicking the ‘spotify.sh’ file in Nautilus, going to Properties -> Permissions and checking the ‘Allow executing file as program’ checkbox.
Hope this helps. Feel free to ask any more questions if you are still having issues.
No luck I’m afraid. I do have the spotify.sh file marked as executable, checked via Nautilus.
I’ve been through all the steps again, double checking the path for Spotify, that I’ve replaced username with my log in name, and entered the correct names and values in Firefox about:config
I’m using Ubuntu Karmic, Firefox 3.5.5 and Spotify 0.3.22 via Wine 1.1.31, but all I get when I try to open a Spotify playlist link is “Firefox doesn’t know how to open this address, because the protocol (spotify) isn’t associated with any program.”
I have this same situation. I tried both about:config and gconftool but the Firefox doesn’t recognize links.
Actually maedox had already posted a resolution to this and now I got it working nicely. I just missed it at first:
“PS to the anyone having problems on Karmic; You may have to add a boolean “false” named “network.protocol-handler.expose.spotify” in about:config to get things going.”
I have this working with Ubuntu Karmic, Firefox 3.5.5, Spotify 0.3.22 and Wine 1.0.1. The Wine version being the only obvious difference here may be the cause.
I’ll take a look into this further.
Great work dude, it works!
Only one question; Do you know if there is a way to focus the Spotify window when one clicks a link in firefox? When I click on a link Spotify does what it is supposed to, but the window does not pop to the front unless it is already minimized to the tray. If it only minimized or behind another window it does not get focus.
@maedox
Glad it all works for you!
Regarding the focusing, does this behaviour differ from how it performs in Windows? If so, I would assume this is a bug in Wine. You can try different versions of Wine. Alternatively, run Spotify (via Wine) in a terminal, attempt what you are describing, and see if you notice any ‘stub’ or ‘todo’ output appear. If so, this would suggest the code to handle this refocusing is not yet implemented and may be in the works.
Tell me how it goes!
Spotify does not get focus in Windows either, but the taskbar indicates it wants attention, which is not the case in Ubuntu.
It is not really a big deal, I just thought I would mention it.
Wine output from a terminal window:
—————————————————
$ wine “$HOME/.wine/drive_c/Program Files/Spotify/spotify.exe” /uri “spotify:artist:2yzxX2DI9LFK8VFTyW2zZ8″
fixme:mixer:ALSA_MixerInit No master control found on HDA ATI HDMI, disabling mixer
fixme:reg:GetNativeSystemInfo (0×745513) using GetSystemInfo()
fixme:toolhelp:CreateToolhelp32Snapshot Unimplemented: heap list snapshot
fixme:imagehlp:CheckSumMappedFile (0x26d0000, 2154492, 0x78e5d4, 0x78e5d8): stub
fixme:debugstr:CheckRemoteDebuggerPresent (0xffffffff)->(0x7929f0): Stub!
—————————————————
I have no idea what to make of it, but it seems you may be right.
I am using Ubuntu 9.10 with wine version 1.1.31 btw.
PS to the anyone having problems on Karmic; You may have to add a boolean “false” named “network.protocol-handler.expose.spotify” in about:config to get things going.
Thank you.
> You may have to add a boolean “false” named “network.protocol-handler.expose.spotify” in about:config to get things going.
That did the trick for me.(the other lines and gconftool-2 didn’t)
@maedox
If you wish, you can probably report this as a bug at http://bugs.winehq.org/
More information about reporting bugs in Wine is available here: http://wiki.winehq.org/Bugs
It seems that in gnome at least with firefox 3.0.17 the about:config method doesn’t work at all. I had to do
gconftool-2 –set /desktop/gnome/url-handlers/spotify/command ‘dir_to/spotify.sh %s’ –type String
gconftool-2 –set /desktop/gnome/url-handlers/spotify/enabled –type Boolean true
and then choose the spotify.sh app in any case the first time I used a spotify link.
Hey, thanks! That worked for me. I couldn’t get the about:config to work either, but gconftool-2 does the trick.
I came across this:
http://neo22s.com/spotify-links/
I know it says for Chrome, but because this is a Gnome config change, it should work for all browsers (via xdg-open). Confirmed working for Firefox 3.6.4 and Chromium 6.0.614.0 (48240).
Hi. There is native version for inux already. Could you tell me how make the script work with the browsers? I guess the modification of the script is simple but I am just a dumb end user
What exactly are you asking?
If you install the native Linux version in Gnome you don’t need to do anything. Support for that should be posted in Spotify’s GetSatisfaction portal.
with the spotify native for whatever reason if I clicked on a playlist on firefox it asked me which application I wanted the link to run on, but if I selected spotify nothing happened.
BUT I found out how to make it work.I had to put these command lines on a terminal. Im using ubuntu 10.04
gconftool-2 -t string -s /desktop/gnome/url-handlers/spotify/command “/usr/bin/spotify -uri %s”
gconftool-2 -t bool -s /desktop/gnome/url-handlers/spotify/needs_terminal false
gconftool-2 -t bool -s /desktop/gnome