A spotify daemon
Switch branches/tags
v0.2.3 v0.2.2 v0.2.1 v0.2 v0.1.1 v0.1 untagged-f40914fedc45c74a3412 untagged-dde65f799b1c3d5026af untagged-d1179e3cefbd810b9133 untagged-d9d121b8e4f108a7a1c8 untagged-d7eebecd9b49402f02db untagged-d7c10897cc9c68aebdbc untagged-cf4982bc2e84cf2edf1f untagged-c97ae6f8b1e521f55518 untagged-c16e4f3b11b9c06ccf49 untagged-c9f4ef227dea332f153a untagged-b246fdc84a18ce248071 untagged-b5f358442cf723fb9b50 untagged-aeedb99aec604a4e1aee untagged-ad661221349c1b7fd273 untagged-ac2f254b071b7d955786 untagged-ab19d6eac6820e122dc8 untagged-a17c5374551d3eb746d9 untagged-61816928a53a74993dc0 untagged-5714215a4cf45130004f untagged-611892beb3cb303a9b6f untagged-547204f240120f99dad4 untagged-9611d797f6d3344e6a8e untagged-8884b1b8febe0762e0d1 untagged-8746a31e8a06ca90a947 untagged-8149c350afac042508de untagged-7542bdb173909d014e1e untagged-7284e67c917ce517a421 untagged-3801a7fdd0b31c22ade8 untagged-02783d60bbc126a4ac19 untagged-1381c4c12d8add2ba63e untagged-77ab045b5ee8496b69ac untagged-72f18e448e5d82f76c4d untagged-59a07c0000786137b653 untagged-56e98d0b8ff58b640817 untagged-51eaced28c1f5eba0893 untagged-49c187b9535b150bb4c7 untagged-49c75d3077998929f42e untagged-43c238bbd54def53fa4f untagged-14c2771fccc889ba0046 untagged-11c53f81749b6321c168 untagged-10dabd29ba8d8928653c untagged-8d1809f9710e3af4cda7 untagged-7cf7ff718c3f15a28c1e untagged-6f7a8d1f5b0f198ce6a5 untagged-06d48d48844c5fbce483 untagged-4f29c7b5d5c3026f3517 untagged-4cc466d87efba3c28f5a untagged-4c6ea6778ddb64fb615c untagged-3c495314369a39e05a46 untagged-2dfc6a8728585e058ff6 untagged-2cb556328b5f57a0fe2b untagged-2b5f5052ec8409bcb839 untagged-01fde2ee909a8b6e792b untagged-1d829595ab5fe28e04cf untagged-452658987034c42dfa0b
Nothing to show
Clone or download
Latest commit 010b0ca Oct 21, 2018

README.md

Spotifyd

An open source Spotify client running as a UNIX daemon. Spotifyd 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.

Spotifyd requires a Spotify Premium account.

What happened to the old spotifyd, written in C?

Unfortunately, Spotify decided to kill the libspotify library we used, and hence we had no choice but to rewrite everything.

Installing

Travis CI builds binaries for systems running Linux on AMD64 and ARMv6 which should run on any Raspberry Pi model. The binaries can be found here. Other systems have to build from source for now. You will need the ALSA package for your distribution, e.g. libasound2-dev on Ubuntu.

Detailed install instructions can be found on the wiki.

Build from source

The Rust compiler and Cargo package manager are needed:

cargo build --release

The resulting binary will be placed in target/release/spotifyd.

The default is to build spotifyd with an ALSA backend, but it is possible to build with other audio backends, making Spotifyd availible on platforms other than Linux, by adding the --no-default-features argument to cargo and supplying an alternative backend (see the Configuration section).

Configuration

Spotifyd will search for a file name spotifyd.conf in the XDG config directories (meaning, a users local config is placed in ~/.config/spotifyd/spotifyd.conf, a system wide config is in /etc/spotifyd.conf or in /etc/xdg/spotifyd/spotifyd.conf) and has the following format:

[global]
username = USER
password = PASS
backend = alsa
device = alsa_audio_device # Given by `aplay -L`
mixer = PCM
volume-control = alsa # or alsa_linear, or softvol
#onevent = command_run_on_playback_event
device_name = name_in_spotify_connect # Cannot contain spaces
bitrate = 96|160|320
cache_path = cache_directory
volume-normalisation = true
normalisation-pregain = -10

Every field is optional; Spotifyd can even run without a configuration file. Options can also be placed in a [spotifyd] section which takes priority over the [global] section. This is useful when you run applications related to Spotifyd which shares some, but not all, options with Spotifyd.

Values can be surrounded by double quotes (") which is useful if the value contains the comment character (#).

Command Line Arguments

spotifyd --help gives an up-to-date list of available arguments. The command line arguments allows for specifying a PID file, setting a verbose mode, run in no-daemon mode, among other things.

Audio Backend

By default, the audio backend is ALSA, as ALSA is available by default on a lot of machines and requires no extra dependencies. There is also support for pulseaudio and portaudio.

PulseAudio

To use PulseAudio, compile with the --features flag to enable it:

cargo build --release --features pulseaudio_backend

You will need the development package for PulseAudio, as well as build-essential or the equivalent in your distribution.

PortAudio

To use PortAudio (works on OSX), compile with the --features flag to enable it:

cargo build --release --no-default-features --features portaudio_backend

You will need the development package for PortAudio (brew install portaudio), as well as build-essential or the equivalent in your distribution.

Usage

Spotifyd communicates over the Spotify Connect protocol, meaning that it can be controlled from the official Spotify client on Android/iOS/Desktop.

For a more lightweight and scriptable alternative, there is the Spotify Connect API.

D-Bus MPRIS

Spotifyd implements D-Bus MPRIS which means it can be controlled by some generic media playback controllers such as playerctl as well as some tools specifically designed for use with the official Spotify client such as sp (requires changing the DBus service name to spotifyd instead of spotify).

The D-Bus server is currently experimental. Enable the dbus_mpris feature when compiling to try it out.

Running as a systemd service

A systemd.service unit file is provided to help run spotifyd as a service on systemd-based systems. The file contrib/spotifyd.service should be copied to either:

/etc/systemd/user/
~/.config/systemd/user/

Packagers of systemd-based distributions are encouraged to include the file in the former location. End-user should prefer the latter.

Control of the daemon is then done via systemd. The following example commands will run the service once and enable the service to always run on login in the future respectively:

systemctl --user start spotifyd.service
systemctl --user enable spotifyd.service

Logging

In --no-daemon mode, the log is written to standard output, otherwise it is written to syslog, and where it's written can be configured in your system logger.

The verbose mode adds more information; please enable this mode when submitting a bug report.

Common Issues

  • Spotifyd will not work without Spotify Premium
  • The device name cannot contain spaces

Credits

This project would not have been possible without the amazing reverse engineering work done in librespot, mostly by plietar.