Spotify on FreeBSD

Setting up terminal Spotify application: spotifyd + spotify-tui

After my recent tweet

Finally set up #spotify-tui + spotifyd on #FreeBSD. pic.twitter.com/OKUtxGgH0t

— Evgeny Khabarov 🇨🇦 (@eekhabarov) March 29, 2020

I was asked questions about the set up, so this article is an answer for them.

Due to Spotify has no official application for my beloved FreeBSD and Spotify web player requires enabled DRM in browser, I have no idea what DRM is and what it’s used for, as well as I don’t like browser applications. Anyway I’ve started to look for terminal app and I found it! Please welcome, spotify-tui, written in Rust it’s really cool app allow you to manage your music collection.

spotify-tui

This app is available in FreeBSD ports/packages and easily can be installed with

% doas pkg install spotify-tui-0.11.0

After installation is finished you have to create ClientID/ClientSecret credentials and authorize your the app within Spotify API. The process is pretty straightforward and clearly described in installation instructions of the project.

spotifyd

When you start spotify-tui you will be needed to point a device to play tracks. That’s where spotifyd comes to play. Also written in Rust and available in FreeBSD ports/packages, it

…streams music just like the official client, but is more lightweight and supports more platforms. Spotifyd also supports the Spotify Connect protocol, which makes it show up as a device that can be controlled from the official clients.

source

Let’s install it

% doas pkg install spotifyd-0.2.20_3

I’ve tried to start it right away and got an error:

[INFO] No config file specified. Running with default values
[INFO] Using software volume controller.
[ERROR] Caught panic with message: Unknown backend: alsa.

OK, fix config then:

% doas nvim /usr/local/etc/spotifyd.conf

minimal config looks like this:

[global]
username = login
password = password
backend = portaudio

we need only three thing. If with first two everything is clear, backend isn’t. By default backend = alsa, as mentioned in the error above. But what to use in FreeBSD?

Well, just read the README:

# The audio backend used to play the your music. To get
# a list of possible backends, run `spotifyd --help`.
backend = alsa

nah, it couldn’t be such easy, right? :)

% spotifyd -h

actually it is:

OPTIONS:
    -b, --backend <string>   The audio backend to use [possible values: portaudio]

portaudio is what we need here.

As a final steps, just run it:

% spotifyd [--no-deamon]
% spt

By default, spotifyd runs in background, key --no-deamon can be used for debugging stuff. Then in spt choose Spotifyd@<hostname> device.

Enjoy!

Afterwords

I’d like to say “Thank you!” to all contributors of both projects!