Skip to content

Instantly share code, notes, and snippets.

@jjylik
Last active December 3, 2020 14:36
Show Gist options
  • Save jjylik/9f9d21e52a4f5608183cddc41c17ce35 to your computer and use it in GitHub Desktop.
Save jjylik/9f9d21e52a4f5608183cddc41c17ce35 to your computer and use it in GitHub Desktop.
Zynthian with Spotify and Radio Helsinki players
#!/bin/bash
if [[ "$PLAYER_EVENT" == "start" || "$PLAYER_EVENT" == "playing" ]]; then
service radiohelsinki stop
n=0
until [ "$n" -ge 3 ]
do
jack_connect librespot:out_0 system:playback_1 &>/dev/null
jack_connect librespot:out_1 system:playback_2 &>/dev/null
n=$((n+1))
sleep 3
done
fi
if [[ "$PLAYER_EVENT" == "stop" || "$PLAYER_EVENT" == "paused" ]]; then
service radiohelsinki start
fi
if [[ "$PLAYER_EVENT" == "volume_set" && "$VOLUME" == "0" ]]; then
service radiohelsinki stop
fi
[Unit]
Description=Radio helsinki
After=jack2.service network-online.target
Wants=network-online.target
Requires=jack2.service
[Service]
Restart=always
Type=simple
ExecStart=/usr/bin/mplayer -volume 31 -nogui -ao jack -cache 1032 -cache-min 10 "http://stream.radiohelsinki.fi:8006/;"
[Install]
WantedBy=multi-user.target
[Unit]
Description=Spotify player
After=radiohelsinki.service
Wants=network-online.target
[Service]
Restart=always
Type=simple
ExecStart=/root/librespot/target/release/librespot --name hima --backend jackaudio --username <REDACTED> --password <REDACTED> --bitrate 320 --disable-audio-cache --enable-volume-normalisation --mixer-linear-volume --initial-volume=100 --onevent /root/connect-spotify-jack.sh
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment