Skip to content

Instantly share code, notes, and snippets.

@OlofFredriksson
Last active December 25, 2024 07:48
Show Gist options
  • Save OlofFredriksson/6364793 to your computer and use it in GitHub Desktop.
Save OlofFredriksson/6364793 to your computer and use it in GitHub Desktop.
Install Spop on Raspberry Pi
# Made by Olof Fredriksson
# http://olof.nu
# https://github.com/oloffredriksson
# Tested on Raspberry Pi with Raspbian OS. Will probably work on Ubuntu and other Debian based systems, just make sure you install correct libspotify for your process architecture.
# Big thanks to Thomas Jost for creating Spop and uploading the project to Github (https://github.com/Schnouki/spop)
#Thanks to Björn Andersson (https://github.com/bjornandersson) for testing, reviewing and contributing to this guide.
# Changelog
# 1.0 2013-08-28 : First public release
# For fresh install of Raspbian (I used 2013-07-26-wheezy-raspbian.zip when writing this guide)
## PROLOGUE
# When I installed Spop on my Raspberry Pi, I had some different problems before it started to work like intended, and that’s why I wrote this guide. My goal is to help other people install this awesome script as smooth as possible!
# The biggest problem I had to get this running on my Pi was that the Wheezy repository contains an old Glib-dev version, which causes problems when you try to install json-glib and running the spop daemon.
# I tried to build Glib myself but ended up with a lot of other errors so I decided to see if could make it work with this version as well. You will know what changes I have done later in this guide.
# Good luck!
## 1 UPDATE YOUR PI AND INSTALL NEEDED TOOLS
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install cmake git telnet vim
## 2 RETRIEVE SPOP CODE
# Get spop from github
# Go to home folder and create a git folder
cd && mkdir gitrepos && cd gitrepos
git clone git://github.com/Schnouki/spop.git
# Add g_type_init into main.c
# Due to old glib (pre 2.36) version in Wheezy repository, we need to call g_type_init before the application starts, you will otherwise receive following error message:
# GLib-GObject 2013-07-28 00:36:35 [CRIT] /build/glib2.0-AWe8Zn/glib2.0-2.33.12+really2.32.4/./gobject/gtype.c:2722: You forgot to call g_type_init()
# GLib 2013-07-28 00:36:35 [CRIT] g_once_init_leave: assertion `result != 0' failed
# GLib-GObject 2013-07-28 00:36:35 [CRIT] g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
# It’s very simple to fix this issue, just add following lines in Main.C (line 96), before g_set_application_name("spop " SPOP_VERSION);
#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
# Create the config file for the spopd deamon
mkdir -p ~/.config/spop
cp spop/spopd.conf.sample ~/.config/spop/spopd.conf
# Open the config file with your favourite editor
vim ~/.config/spop/spopd.conf
# Update audio plugin to "ao", and define your Spotify account
# Also, change the log path to something in your home-folder to avoid permission problems, i.e /home/pi/spopd.log
# So, check what dependencies we need to install
cd /home/pi/gitrepos/spop
cmake -DCMAKE_INSTALL_PREFIX=/home/pi/spop
# According to the error log, i miss following required packages:
# libspotify
# glib-2.0
# gmodule-2.0
# gthread-2.0
# json-glib-1.0
# And spop also requires an audio plugin, ao (The install script wont complain if you miss it though, but you can’t start the daemon without it)
# Tip, to verify that you got the packages correctly installed, you can try the following command: pkg-config --print-provides glib-2.0, if output is empty, you probably miss the library
## 3 INSTALL LIBRARIES
# Lets create a temp folder where we can put all temporary files
cd && mkdir temp && cd /home/pi/temp
# 1 : Libspotify
wget https://developer.spotify.com/download/libspotify/libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release.tar.gz
tar -xf libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release.tar.gz
cd libspotify-12.1.103-Linux-armv6-bcm2708hardfp-release/
sudo make install
# Verify that the package is installed correctly
pkg-config --print-provides libspotify
# Output : libspotify = 12.1.103, Seems to be working
# 2 : glib-2.0, gmodule-2 and gthread-2.0
# A problem with Wheezy is that the latest glib is not included in the libglib2.0-dev (2.33.12+really2.32.4-5 instead of 2.36.x which leads to that you can’t install the latest json glib.)
sudo apt-get install libglib2.0-dev
# 3 : json-glib-1.0
# Install version 0.14 instead of latest (Which is 0.16 right now) due to old glib
cd /home/pi/temp
wget http://ftp.gnome.org/pub/GNOME/sources/json-glib/0.14/json-glib-0.14.0.tar.xz
tar -xf json-glib-0.14.0.tar.xz
cd json-glib-0.14.0/
./configure --prefix=/usr
make
sudo make install
# 4 : Libao
sudo apt-get install libao-dev
## COMPILE AND BUILD
cd /home/pi/gitrepos/spop
cmake -DCMAKE_INSTALL_PREFIX=/home/pi/spop
make
sudo make install
## 4 CLEANUP
# Remove the temporary folder with all downloaded library files
rm -rf /home/pi/temp
## 5 STARTUP
# Active audio
sudo modprobe snd_bcm2835
# Define audio output, Replace <n> with 0 for auto, 1 = analog and 2 = hdmi
# sudo amixer cset numid=3 <n>
# I am using the analog audio, so lets enable that!
sudo amixer cset numid=3 1
# Tip : Before we start, tail the log file so you can see if any errors occur
tail -f /home/pi/spopd.log
# Startup
LD_LIBRARY_PATH=/home/pi/spop/lib /home/pi/spop/bin/spopd
# Connect to the daemon through telnet and are you free to play around :-)
telnet localhost 6602
## 6 AUDIO QUALITY ON RASPBERRY PI
# When I bought my Pi I was aware that the audio quality wasn’t going to be perfect. In my opinion, it’s too bad to use as music server so my plan is to buy a usb sound card and see if it becomes better with that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment