Configuration - dtcooper/raspotify GitHub Wiki

Raspotify works out of the box and should be discoverable by Spotify Connect on your local network, however you can configure it by editing Raspotify's config file. which passes arguments to librespot. See the librespot wiki for details and the Troubleshooting section of this wiki for troubleshooting and audio setup tips.

# /etc/raspotify/conf -- Arguments/configuration for librespot

# A non-exhaustive list of librespot options and flags.

# Please see:
# - https://github.com/dtcooper/raspotify/wiki
# - https://github.com/librespot-org/librespot/wiki/Options
# for configuration details and a full list of options and flags.

# You can also find a full list with `librespot -h`.

# To avoid name collisions environment variables must be prepended with
# `LIBRESPOT_`, so option/flag `foo-bar` becomes `LIBRESPOT_FOO_BAR`.

# Invalid environment variables will be ignored.

# Raspotify defaults may vary from librespot defaults.

# Boolean values are represented as flags, which are either enabled
# (uncommented) or disabled (commented, default). Note that `off` is considered
# as TRUE and should not be used.

# Commenting out the environment variable will fallback to librespot's default
# unless otherwise noted.

# Empty values for string variables may cause errors.

###################################
#    CONFIGURATION STARTS HERE    #
###################################

# Spotify access-token to sign in with. Must include 'streaming' scope. A token
# can be obtained using librespot-oauth or Spotify's OAuth flow. Ideally used
# alongside --cache/--system-cache options.
#LIBRESPOT_ACCESS_TOKEN=

# ALSA mixer control, e.g. PCM, Master or similar. Defaults to PCM.
#LIBRESPOT_ALSA_MIXER_CONTROL=PCM

# ALSA mixer device, e.g. hw:0 or similar from aplay -l. Defaults to --device
# if specified, default otherwise.
#LIBRESPOT_ALSA_MIXER_DEVICE=

# ALSA mixer index, index of the card’s mixer. Defaults to 0.
#LIBRESPOT_ALSA_MIXER_INDEX=0

# Connect to an AP with a specified port. If no AP with that port is present a
# fallback AP will be used. Available ports are usually 80, 443 and 4070.
#LIBRESPOT_AP_PORT=

# Autoplay similar songs when your music ends.
# Respects client autoplay setting if commented out (default).
#LIBRESPOT_AUTOPLAY=

# Audio backend to use. Define also the device option when using pipe.
#LIBRESPOT_BACKEND=

# Bitrate (kbps): 96, 160, 320. Defaults to 160.
#LIBRESPOT_BITRATE=160

# Path to a directory where files will be cached.
#LIBRESPOT_CACHE=

# Limits the size of the cache for audio files; supports K, M, G suffixes.
#LIBRESPOT_CACHE_SIZE_LIMIT=

# Audio device to use. Use ? to list options if using alsa, portaudio or rodio.
# Enter the path to the output when using pipe. Defaults to the backend's
# default.
#LIBRESPOT_DEVICE=

# Displayed device type: computer, tablet, smartphone, speaker, tv, avr
# (Audio/Video Receiver), stb (Set-Top Box), audiodongle, gameconsole,
# castaudio, castvideo, automobile, smartwatch, chromebook, carthing,
# homething. Defaults to speaker.
#LIBRESPOT_DEVICE_TYPE=speaker

# Disable caching of the audio data.
# Enabling audio data caching can take up a lot of space
# if you don't limit the cache size with LIBRESPOT_CACHE_SIZE_LIMIT.
# It can also wear out your Micro SD card. You have been warned. 
LIBRESPOT_DISABLE_AUDIO_CACHE=

# Disable caching of credentials.
# Caching of credentials is not necessary so long as
# LIBRESPOT_DISABLE_DISCOVERY is not set.
LIBRESPOT_DISABLE_CREDENTIAL_CACHE=

# Disable zeroconf discovery mode.
# If oauth is not configured, this option must be commented out.
#LIBRESPOT_DISABLE_DISCOVERY=

# Disables gapless playback by forcing the sink to close between tracks.
#LIBRESPOT_DISABLE_GAPLESS=

# Dither algorithm: none, gpdf, tpdf, tpdf_hp. Defaults to tpdf for formats
# S16, S24, S24_3 and none for other formats.
#LIBRESPOT_DITHER=

# When uncommented, run PROGRAM set by --onevent before sink is opened and
# after it is closed.
#LIBRESPOT_EMIT_SINK_EVENTS=

# Enables volume normalisation for librespot.
# Plays all tracks at approximately the same apparent volume.
LIBRESPOT_ENABLE_VOLUME_NORMALISATION=

# Output format: F64, F32, S32, S24, S24_3, S16. Defaults to S16.
#LIBRESPOT_FORMAT=S16

# Initial volume in % from 0-100. Default for softvol: 50. For the alsa mixer:
# the current volume.
#LIBRESPOT_INITIAL_VOLUME=50

# Mixer to use: softvol, alsa. Defaults to softvol.
#LIBRESPOT_MIXER_TYPE=softvol

# Device name.
# Raspotify defaults to "raspotify (*hostname)".
# Librespot defaults to "Librespot".
#LIBRESPOT_NAME="Librespot"

# Specify the normalisation method to use: basic, dynamic. Defaults to dynamic.
#LIBRESPOT_NORMALISATION_METHOD=dynamic

# Specify the normalisation gain type to use: track, album, auto. Defaults to auto.
#LIBRESPOT_NORMALISATION_GAIN_TYPE=auto

# Pregain (dB) applied by the normalisation. Defaults to 0.
#LIBRESPOT_NORMALISATION_PREGAIN=0

# Threshold (dBFS) to prevent clipping. Defaults to -2.0.
#LIBRESPOT_NORMALISATION_THRESHOLD=-2.0

# Attack time (ms) in which the dynamic limiter is reducing gain. Defaults to 5.
#LIBRESPOT_NORMALISATION_ATTACK=5

# Release or decay time (ms) in which the dynamic limiter is restoring gain.
# Defaults to 100.
#LIBRESPOT_NORMALISATION_RELEASE=100

# Knee steepness of the dynamic limiter. Default is 1.0.
#LIBRESPOT_NORMALISATION_KNEE=1

# The path to a script that gets run when one of librespot's events is triggered.
#LIBRESPOT_ONEVENT=

# Pass a raw stream to the output. Only works with the pipe and subprocess backends.
#LIBRESPOT_PASSTHROUGH=

# Password authentication does _NOT_ work anymore.
# Your options are either OAuth or Zeroconf discovery.
#LIBRESPOT_PASSWORD=

# Use a proxy for HTTP requests. Proxy should be an HTTP proxy in the form
# http://ip:port, and can also be passed using the all-lowercase http_proxy
# environment variable.
#LIBRESPOT_PROXY=

# Only log warning and error messages.
LIBRESPOT_QUIET=

# Directory where system files (credentials, volume) will be cached.
#LIBRESPOT_SYSTEM_CACHE=

# Username to use cached credentials for.
#LIBRESPOT_USERNAME=

# Enable verbose output.
#LIBRESPOT_VERBOSE=

# Volume control type cubic, fixed, linear, log. Defaults to log.
#LIBRESPOT_VOLUME_CTRL=log

# Range of the volume control (dB). Default for softvol: 60. For the alsa
# mixer: what the control supports.
#LIBRESPOT_VOLUME_RANGE=60

# Zeroconf backend to use. Valid values are avahi, dns-sd and libmdns, if
# librespot is compiled with the corresponding feature flags.
# Note that, for now, Raspotify is built with only the avahi backend.
#LIBRESPOT_ZEROCONF_BACKEND=avahi

# The port the internal server advertises over zeroconf: 1 - 65535.
# Ports <= 1024 may require root privileges.
#LIBRESPOT_ZEROCONF_PORT=

# Comma-separated interface IP addresses on which zeroconf will bind (Example
# "192.168.0.10,10.0.0.10"). Defaults to all interfaces. Ignored by DNS-SD.
#LIBRESPOT_ZEROCONF_INTERFACE=

###########################################
# This is NOT a librespot option or flag. #
###########################################

# This modifies the behavior of the Raspotify service.
# If you have issues with this option DO NOT file a bug with librespot.
# 
# By default librespot "download buffers" tracks, meaning that it downloads
# the tracks to disk and plays them from the disk and then deletes them when
# the track is over. This practice is very common, many other audio frameworks
# and players do the exact same thing as a disk based tmp cache is easy to use
# and very resilient. That being said there may be cases where a user may want
# to minimize disk read/writes.
#
# Commenting this out will cause librespot to use a tmpfs so that provided there
# is enough RAM to hold the track nothing is written to disk but instead to a tmpfs.
# See https://github.com/dtcooper/raspotify/discussions/567
# And https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html
TMPDIR=/tmp

After editing restart the daemon by running: sudo systemctl restart raspotify

Please see the Configuration Migration Page to learn how to migrate your setting to version 0.31.4+ if upgrading from an older release.

With the exception of fixing typos please do NOT edit this or any other Wiki page without at least opening a discussion.