Last active
January 29, 2017 10:47
-
-
Save reitermarkus/0c086bd7dbbd8c122905da7173b6e3c4 to your computer and use it in GitHub Desktop.
Raspberry Pi 3 A2DP Bluetooth Audio Receiver (Raspbian Jessie Lite)
This file contains hidden or 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
#!/usr/bin/env sh | |
NAME="Fiat 500 L" | |
# Set Bluetooth Device Name | |
echo "PRETTY_HOSTNAME=\"${NAME}\"" | sudo tee /etc/machine-info | |
# Allow 'pi' user to change bluetooth settings. | |
sudo usermod -a -G lp pi | |
# Change Bluetooth Device Class | |
sudo sed -i -E 's/#?(Class = 0x)[0-F]{6}/\120041C/' /etc/bluetooth/main.conf | |
# Make Bluetooth Discoverable on Startup | |
if ! grep -q 'piscan' /etc/rc.local; then | |
sudo sed -i 's/^\s*exit 0\s*$/hciconfig hci0 piscan\n\n&/gm' /etc/rc.local | |
fi | |
# Upgrade all installed packages. | |
sudo apt-get update | |
sudo apt-get -y upgrade | |
# Install PulseAudio. | |
sudo apt-get -y install pulseaudio | |
sudo apt-get -y install pulseaudio-module-bluetooth | |
if ! grep -q 'exit-idle-time = -1' /etc/pulse/daemon.conf; then | |
sudo sed -i 's/; exit-idle-time = 20.*/&\nexit-idle-time = -1/' /etc/pulse/daemon.conf | |
fi | |
if ! grep -q 'resample-method = trivial' /etc/pulse/daemon.conf; then | |
sudo sed -i 's/; resample-method = speex-float-1.*/&\nresample-method = trivial/' /etc/pulse/daemon.conf | |
fi | |
# Load PulseAudio on startup. | |
if ! grep -q 'pulseaudio -D' /etc/rc.local; then | |
sudo sed -i 's/^\s*exit 0\s*$/pulseaudio -D\n\n&/gm' /etc/rc.local | |
fi | |
# Set Volume | |
amixer -q set Master 100% | |
pactl set-sink-volume 0 100% | |
sudo tee /etc/shairport-sync.conf <<EOF | |
// General Settings | |
general = { | |
name = "${NAME}"; | |
volume_range_db = 40; | |
}; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment