Contact
Offices

Compendium of Spotify on Linux Tips

Joseph Conway
tux.jpg Getting Spotify to work nicely on Linux Note: the Linux Spotify client will only work with a premium Spotify account. I spoke at the NYC PostgreSQL Users' Group meeting in December, and while there someone mentioned that Spotify is a great music service (and that they are using PostgreSQL!). So I decided to give it a try. The issue was that, while it can be made to work on Linux, the process of making it work well on Linux is less than simple. I decided to document what I did (and my sources) as I had to pull information from several sources and added a few modifications of my own. There are two main problems to deal with:
  1. Getting the program itself installed and running
  2. Getting Linux and your browser to handle the spotify protocol so that, for example, clicking on playlist URLs will work correctly
The answer to problem number one depends in part on your Linux distribution. I am only going to cover Ubuntu and Fedora here -- extrapolation is left as an exercise for the reader. On Ubuntu (I'm using 11.10), the directions from Spotify seems to work fine. I'll paste them here for the sake of completeness:
# On Ubuntu
# This gets you the older released client
# From http://www.spotify.com/us/download/previews/
# -----------
# 1. Add this line to your list of repositories by
#    editing your /etc/apt/sources.list
deb http://repository.spotify.com stable non-free
 
# 2. If you want to verify the downloaded packages,
#    you will need to add our public key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4E9CFF4E
 
# 3. Run apt-get update
sudo apt-get update
 
# 4. Install spotify!
sudo apt-get install spotify-client-qt
I just noticed that the Ubuntu directions result in the older client working, not the shiny new preview version. See below for instructions to get the preview client working
# On Ubuntu, new preview client
# From
# http://getsatisfaction.com/spotify/topics/try_out_the_linux_apps_client_beta_preview
# -----------
wget \
http://download.spotify.com/preview/spotify-client_0.8.0.1031.ga1569aa.552-1_amd64.deb
ar vx spotify-client_0.8.0.1031.ga1569aa.552-1_amd64.deb
tar -xzvf data.tar.gz
cp -rf ./usr /
 
# From
# http://meltingrobot.wordpress.com/2011/11/08/spotify-installation-on-fedora-16/
# modified to handle passing of arguments
 
vi /usr/local/bin/spotify
 
# add the following lines to /usr/local/bin/spotify
8<--------------------------
#!/bin/bash
 
/bin/rm -rf ~/.cache/spotify
/usr/share/spotify/spotify $*
8<--------------------------
 
# make the script executable
chmod +x /usr/local/bin/spotify
 
# arrange to use the script in place of the binary to work
# around a known issue causing segfaults
rm /usr/bin/spotify
ln -s /usr/local/bin/spotify /usr/bin/spotify
 
# create symlinks to work around library mismatches
ln -s /usr/lib/x86_64-linux-gnu/libplc4.so /usr/lib/x86_64-linux-gnu/libplc4.so.0d
ln -s /usr/lib/x86_64-linux-gnu/libnspr4.so /usr/lib/x86_64-linux-gnu/libnspr4.so.0d
On Fedora things are complicated by the fact that Spotify no longer distributes an RPM - at least not that I could find. There are several recipes for solving this dilemma that can be found scattered around the Internet. Here is what I used:
# On Fedora (I am on Fedora 15)
# From http://www.passwdshadow.com/
yum -y install perl-ExtUtils-MakeMaker gcc qt-webkit rpm-build git
cd /tmp
git clone git://git.kitenet.net/alien
cd alien
perl Makefile.PL; make; make install
wget \
http://download.spotify.com/preview/spotify-client_0.8.0.1031.ga1569aa.552-1_amd64.deb
/usr/local/bin/alien --to-rpm \
spotify-client_0.8.0.1031.ga1569aa.552-1_amd64.deb
rpm -Uvh --nodeps spotify-client-0.8.0.1031.ga1569aa.552-2.x86_64.rpm
ln -s /usr/lib64/libssl.so.1.0.0e /usr/lib64/libssl.so.0.9.8
ln -s /lib64/libcrypto.so.1.0.0e /lib64/libcrypto.so.0.9.8
ln -s /usr/lib64/libnss3.so /usr/lib64/libnss3.so.1d
ln -s /usr/lib64/libnssutil3.so /usr/lib64/libnssutil3.so.1d
ln -s /usr/lib64/libsmime3.so /usr/lib64/libsmime3.so.1d
ln -s /lib64/libplc4.so /lib64/libplc4.so.0d
ln -s /lib64/libnspr4.so /lib64/libnspr4.so.0d
 
# From
# http://meltingrobot.wordpress.com/2011/11/08/spotify-installation-on-fedora-16/
# modified to handle passing of arguments
 
vi /usr/local/bin/spotify
 
# add the following lines to /usr/local/bin/spotify
8<--------------------------
#!/bin/bash
 
/bin/rm -rf ~/.cache/spotify
/usr/bin/spotify.bin $*
8<--------------------------
 
# make the script executable
chmod +x /usr/local/bin/spotify
 
# arrange to use the script in place of the binary to work
# around a known issue causing segfaults
mv /usr/bin/spotify /usr/bin/spotify.bin
ln -s /usr/local/bin/spotify /usr/bin/spotify
At this point you should be able to click on the Spotify desktop shortcut and the program will launch. So on to problem number two. One of the key features of Spotify is the ability to share playlists. This is done via a "spotify" protocol URL. Unfortunately at this point neither Linux nor your browser know how to handle this protocol. I have only worked out the specifics for gnome and Firefox, but here they are below:
# Handling the spotify protocol -- e.g. to allow use of http://sharemyplaylists.com
# From http://kb.mozillazine.org/Register_protocol
# -------------------------------------------------
# At shell command prompt:
gconftool-2 -s \
/desktop/gnome/url-handlers/spotify/command '/usr/bin/spotify %s' --type String
gconftool-2 -s \
/desktop/gnome/url-handlers/spotify/enabled --type Boolean true
 
# In Firefox:
#    Type about:config into the Location Bar (address bar) and press Enter.
#    Right-click -> New -> Boolean
#          -> Name: network.protocol-handler.expose.spotify
#          -> Value -> false
# Next time you click a link of protocol-type spotify you will be asked
# which application to open it with. Select /usr/bin/spotify
I think that's everything. I used the preceding successfully on my Fedora 15 desktop and my Ubuntu 11:10 laptop. But use at your own risk -- no guarantees that the foregoing will work or will not eat your data ;-) Hope this helps someone else!
Blog Categories: 

Add new comment

Image CAPTCHA