Spotify on FreeBSD

Originally written: June 3rd, 2021

I've used Spotify for Linux for a while, and I've found it to be one of the best -- if not the best -- desktop application ports to Linux that isn't commercially supported (i.e. Chrome). It ran all features that I used under Windows, never crashed, maintained very modest CPU and RAM usage.

However, probably unsurprisingly, the Spotify desktop application does not support FreeBSD. The situation is worse because none of the BSD-ported browsers (Chromium, Firefox, etc.) have access to Widevine, a proprietary closed-source tool to play Digital Rights Management (DRM) content. This means that none of the browsers can run Spotify, as running Spotify on the browser requires DRM.

Not all hope is lost, however. spotifyd is an awesome tool that allows you to run the Spotify client as a UNIX daemon. Combined with an UI, you can then run Spotify as usual, albeit with a different interface. It works amazingly with FreeBSD -- it even gets picked up by external applications like Discord!

I used spotify-qt for my UI, since the more popular spotify-tui unfortunately has a broken port right now. spotify-qt can be a little slow, but it gets the job done, and having a graphical interface saves me from learning some new keybindings and API's.

Installing the two ports is fairly easy with pkg:

              
pkg install spotifyd
pkg install spotify-qt
              
            

You then need to configure your ~/.config/spotifyd/spotfityd.conf like the following:

              
[global]
username = "your_user_name"
password = "your_password"
backend = "portaudio"
device = "/dev/dsp"
              
            
You might not need the device field, but spotifyd may fail due to erroneous defaults. If it doesn't work for unknown reasons, you can find out the list of devices by putting "?" for device, and running spotifyd --no-daemon to check the list of possible devices.

Even after these configurations, you may get the following error:

              
Loading config from "/home/wonhyuk/.config/spotifyd/spotifyd.conf"
No proxy specified
Using software volume controller.
Caught panic with message: called `Result::unwrap()` on an `Err` value: Os 
{ code: 48, kind: AddrInUse, message: "Address already in use" }
              
            
This happens because the port that spotifyd uses, port 1234, is also used by Avahi. Unless you need Avahi features, a simple hack is to simply kill Avahi, i.e. pkill Avahi. This however means that unless you kill Avahi on boot, automatically starting spotifyd on boot will not work. Instead, I simply go around the issue by opening a tmux server, running spotifyd --no-daemon, and then closing the shell.

We can now set up spotify-qt. You first need to create a Spotify API client and token by logging on to the Spotify Developer Dashboard. Then, just open spotify-qt, and fill in the appropriate API information.

You then need to link this with spotifyd. In Settings > Spotify, set the spotifyd path to /usr/local/bin/spotifyd, and in the Configuration tab, click "Use global config". Now, when you restart spotify-qt, you should be able to see your daemon; once you click it, you'll be able to start playing music!

I really like the "dark theme" provided for spotify-qt. The old "windows" interface with the original colors is also a nice touch, but the dark theme produces a nifty look:

Spotify-qt setup

Very thankful for all the developers out there that make Spotify on FreeBSD possible.