Skip to content

Instantly share code, notes, and snippets.

@tobiasmcnulty
Created December 7, 2021 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobiasmcnulty/666a302e1cd8a3021d88b221c90ae02b to your computer and use it in GitHub Desktop.
Save tobiasmcnulty/666a302e1cd8a3021d88b221c90ae02b to your computer and use it in GitHub Desktop.
- name: Disable onboard audio
replace:
path: /boot/config.txt
regexp: '^dtparam=audio=on$'
replace: '#dtparam=audio=on'
register: disable_onboard
when: dac_type is defined
- name: Enable DAC ({{ dac_type }})
lineinfile:
path: /boot/config.txt
line: 'dtoverlay={{ dac_type }}'
register: enable_dac
when: dac_type is defined
- name: Add asound.conf
blockinfile:
path: /etc/asound.conf
block: |
pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}
create: yes
register: asound_conf
when: dac_type is defined
- name: Rebooting machine
reboot:
when: dac_type is defined and (disable_onboard.changed or enable_dac.changed or asound_conf.changed)
# see https://support.hifiberry.com/hc/en-us/articles/205377651-Configuring-Linux-4-x-or-higher
dac_type: hifiberry-dac
# raspotify bit rate
raspotify_bitrate: 320
raspotify_volume: 100
raspotify_volume_args: --enable-volume-normalisation --linear-volume --initial-volume={{ raspotify_volume }}
- name: Make sure apt can use https sources
apt:
name: apt-transport-https
state: present
- name: Add signing key
apt_key:
url: https://dtcooper.github.io/raspotify/key.asc
state: present
- name: Add repo
apt_repository:
repo: deb https://dtcooper.github.io/raspotify raspotify main
state: present
- name: Install package
apt:
name: raspotify
state: present
- name: Set DEVICE_NAME for each device
replace:
path: /etc/default/raspotify
regexp: '#?DEVICE_NAME=.+$'
replace: 'DEVICE_NAME="{{ raspotify_device_name }}"'
backup: yes
register: raspotify_devname
- name: Set BITRATE for each device
replace:
path: /etc/default/raspotify
regexp: '#?BITRATE=.+$'
replace: 'BITRATE={{ raspotify_bitrate }}'
backup: yes
register: raspotify_bitrate
- name: Set VOLUME_ARGS for each device
replace:
path: /etc/default/raspotify
regexp: '#?VOLUME_ARGS=.+$'
replace: 'VOLUME_ARGS="{{ raspotify_volume_args }}"'
backup: yes
register: raspotify_bitrate
- name: Restart raspotify
systemd:
name: raspotify
state: restarted
when: raspotify_bitrate.changed or raspotify_devname.changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment