Skip to main content

Use Librespot to play songs


librespot is an open source client library for Spotify. It enables applications to use Spotify's service to control and play music and to act as a Spotify Connect receiver. Using this terminal-application in combination with a Spotify-controller like Hutspot, you can play songs from Spotify on your SailfishOS-Device without using the Android-app from Spotify itself. The source code is available on GitHub


Prebuilt package

There is a prebuilt package which a user uploaded to the forum. You can download it here. If you want to change the configuration, you can edit the command in the file /usr/lib/systemd/user/librespot.service.  This package installs Librespot as a service, so you can start and stop it from Hutspot directly.

Building it yourself

You can also get librespot directly an build it on your device. First, you need to install Rust. To do this, open a terminal and execute 

curl --proto '=https' --tlsv1.2 -sSf | sh

After the installation has finished,  you need to restart your session. This can be done by just typing bash and hitting enter. You also need to install a few development packages. To install these, type in a terminal

devel-su pkcon refresh
devel-su pkcon install gcc git alsa-lib-devel -y

Now that you have everything necessary installed, you can get the source code from GitHub

git clone
cd librespot/

After that, you can now build your application using cargo:

cargo build --release --features "alsa-backend pulseaudio-backend"


Controlling Librespot with Hutspot

If you have installed Librespot as a service, you can control Librespot right from the GUI of Hutspot. To do this, tap on the Hamburger-menu (four lines)  in the bottom right corner of Hutspot and navigate to Settings. There, you need to activate "Control Librespot" (Like seen in  this screenshot ). This will start Librespot with Hutspot and terminate it when Hutspot is closed.  On this page, you can also start/stop Librespot manually. This is also possible from the Pull-Down-Menu of the Devices-page (Like seen here).

Starting Librespot from the terminal

You can also start Librespot from the terminal, where you can make your configuration directly. If you have built Librespot on your own, this is the only option to start Librespot. In this case, you need to execute Librespot from the path where you built it. The executeable is typically stored under <PATH TO LIBRESPOT SOURCE>/target/release/.  For more overview of which options are possible for Librespot, you can look here.

Generally, you would want the --username option,  the --cache option (so you don't need to type in your password everytime), the -n option to give the instance a name and the --backend option (which needs to be set to pulseaudio).

An example command could look like this:

/home/defaultuser/librespot/target/release/librespot --cache /home/defaultuser/.cache/librespot --username USERNAME -b 320 -n MyAwesomeLibrespotBuild --backend pulseaudio --device-type smartphone

Setting Librespot as the current device

If Librespot is running, you can use it to play songs from Spotify via Hutspot. To do this, open Hutspot and navigate to the Devices-page. All connected Spotify devices will show up there (which includes Librespot-instances). To use a device, long press on the device and choose "Set as active device" (first option in the menu). Congratulations, you can now play, pause and skip songs via Hutspot which will be played using your SailfishOS-smartphone.
Notice:  The volume of Librespot can't be controlled with the volume-buttons on your device. For that, you need to use the volume-slider in Hutspot.