diff --git a/Dockerfile b/Dockerfile index 6308d82..3ce4c5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN cargo build --release --features alsa_backend FROM debian:bullseye-slim RUN apt-get update && \ - apt-get install -yqq --no-install-recommends libasound2 && \ + apt-get install -yqq --no-install-recommends libasound2 alsa-utils && \ rm -rf /var/lib/apt/lists/* && \ groupadd -r spotify && \ useradd --no-log-init -r -g spotify -G audio spotify diff --git a/README.md b/README.md index 93bdf33..66a15bd 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,35 @@ # Spotifyd docker +[Repo](https://git.kapelle.org/niklas/spotifyd-docker) + +[Docker Hub](https://hub.docker.com/r/djeeberjr/spotifyd) + Run [spotifyd](https://github.com/Spotifyd/spotifyd) inside docker. Inspired by [GnaphronG/docker-spotifyd](https://github.com/GnaphronG/docker-spotifyd). # Setup -You need to add the `/dev/snd` to the container. Because the container uses Alsa you can have only one application use the device. If you have a something else runnig on your system that uses Alsa, you will get an error. +You need to add the `/dev/snd` to the container. + +If the container starts successfully and you still hear no audio then the audio output may be disabled in alsa. In that case you can open bash inside your container and run `alsamixer`. There you can unmute the master. When it comes to alsa i recommend reading the [ArchWiki](https://wiki.archlinux.org/title/Advanced_Linux_Sound_Architecture) on this topic. Check out the `docker-compose.yml` for an example. # Configuration -Following variables are available. +Following variables are available. See the [spotifyd doc](https://spotifyd.github.io/spotifyd/config/File.html) for more information. -`SPOTIFYD_USERNAME` Required. Spotify username. +`USERNAME` Required. Spotify username. -`SPOTIFYD_PASSWORD` Required. Spotify password. +`PASSWORD` Required. Spotify password. -`SPOTIFYD_DEVICE` Name of the device. +`DEVICE` Name of the device. Default: "Spotifyd" +`VOLUME_NORMALISATION` If set to true, enables volume normalisation between songs. + +`NORMALISATION_PREGAIN` The normalisation pregain that is applied for each song. + +`BITRATE` The audio bitrate. 96, 160 or 320 kbit/s. + +`DEVICE_TYPE`# The displayed device type in Spotify clients. Can be `computer`, `tablet`, `smartphone`, `speaker`, `tv`, `avr`, `stb`, `audiodongle`. + +`INITIAL_VOLUME` Volume on startup between 0 and 100. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a14ccf7..12d503a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,6 @@ services: devices: - "/dev/snd:/dev/snd" environment: - - SPOTIFYD_USERNAME=myUsername - - SPOTIFYD_PASSWORD=myPassword - - SPOTIFYD_DEVICE=Spotifyd \ No newline at end of file + - USERNAME=myUsername + - PASSWORD=myPassword + - DEVICE=Spotifyd \ No newline at end of file diff --git a/start.sh b/start.sh index c054946..88c88c3 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,25 @@ #!/usr/bin/env sh -./spotifyd --no-daemon --username "$SPOTIFYD_USERNAME" --password "$SPOTIFYD_PASSWORD" --device-name "$SPOTIFYD_DEVICE" +ARGS="" +if [ -n "$VOLUME_NORMALISATION" ]; then + ARGS="${ARGS} --volume-normalisation" +fi + +if [ -n "$NORMALISATION_PREGAIN" ]; then + ARGS="${ARGS} --normalisation-pregain ${NORMALISATION_PREGAIN}" +fi + +if [ -n "$BITRATE" ]; then + ARGS="${ARGS} --bitrate ${BITRATE}" +fi + +if [ -n "$DEVICE_TYPE" ]; then + ARGS="${ARGS} --device-type ${DEVICE_TYPE}" +fi + +if [ -n "$INITIAL_VOLUME" ]; then + ARGS="${ARGS} --initial-volume ${INITIAL_VOLUME}" +fi + +./spotifyd --no-daemon --username "$USERNAME" --password "$PASSWORD" --device-name "${DEVICE:=Spotifyd}" $ARGS