Last active
March 10, 2018 22:45
-
-
Save alepee/fb2e5d4756ec95ceca95a32359632278 to your computer and use it in GitHub Desktop.
Setup a Spotify Connect client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setup a Spotify Connect client | |
# | |
# Hardware: | |
# - RaspberryPi3 | |
# - Creative Sound Blaster Play2 | |
# | |
# Resources: | |
# https://github.com/plietar/librespot | |
# install dependencies | |
sudo apt-get install build-essential portaudio19-dev git | |
curl https://sh.rustup.rs -sSf | sh | |
git clone [email protected]:plietar/librespot.git | |
# /!\ use a fan or any other way to cool down CPU as program is compiling | |
cd librespot && cargo build --release | |
ln -s target/release/librespot /usr/local/bin/librespot | |
cd - | |
# you need to plugin your USB sound card from here | |
# list your audio devices and get your card and device identifier | |
aplay -l | |
# **** List of PLAYBACK Hardware Devices **** | |
# card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI] | |
# Subdevices: 1/1 | |
# Subdevice #0: subdevice #0 | |
# card 1: S2 [Sound Blaster Play! 2], device 0: USB Audio [USB Audio] | |
# Subdevices: 1/1 | |
# Subdevice #0: subdevice #0 | |
# in this example the identifier is "hw:1,0" for card 1, device 0 | |
# note that this address can change and depends on your system setup | |
# set usb interface as default | |
# https://github.com/plietar/librespot/issues/69#issuecomment-201951418 | |
sudo cat > /etc/asound.conf <<HEREDOC | |
pcm.!default { | |
type plug | |
slave.pcm "hw:1,0" | |
} | |
HEREDOC | |
alsactl --force restore | |
# test soundcard (dual channel and 48kHz) | |
speaker-test -c 2 -r 48000 | |
# start librespot client for the first time ! | |
librespot --cache /var/cache/librespot \ | |
--name HiFi \ | |
--username <SPOTIFY_USERNAME> \ | |
--password <SPOTIFY_PASSWORD> \ | |
--bitrate 320 | |
# add librespot to init.d (autostart on boot) | |
sudo cat > /etc/init.d/librespot <<HEREDOC | |
/usr/local/bin/librespot --cache /var/cache/librespot \ | |
--name HiFi \ | |
--username <SPOTIFY_USERNAME> \ | |
--password <SPOTIFY_PASSWORD> \ | |
--bitrate 320 | |
HEREDOC | |
# restart and test | |
sudo reboot now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add unit file for systemd
add crontab to empty cache directory every morning at 5am
sudo crontab -e