music: Add the base audio server
Some checks failed
Test / build (push) Failing after 59s

This commit is contained in:
polyfloyd 2025-05-14 23:45:03 +02:00
parent 7cd44bbe53
commit 6927806972
5 changed files with 51 additions and 3 deletions

View file

@ -2,4 +2,6 @@ music_audio_user: audio
music_audio_group: audio
music_librespot_user: librespot
music_pulse_server: /tmp/pipewire-pulse-socket
music_mqtt_mpd_volume: bitlair/music/space/volume

View file

@ -0,0 +1,42 @@
---
- name: Install pipewire
apt:
name:
- pipewire
- pipewire-jack
- pipewire-pulse
- pulseaudio-utils
- pulsemixer
state: present
- name: Add audio group
group:
name: audio
system: true
- name: Set PULSE_SERVER env var for all shells
copy:
dest: /etc/profile.d/pulse-server.sh
content: |+
# Ansible managed
export PULSE_SERVER={{ music_pulse_server }}
- name: Create pipewire-pulse config dir
file:
path: /etc/pipewire/pipewire-pulse.conf.d/
state: directory
- name: Configure system socket
ansible.builtin.copy:
dest: /etc/pipewire/pipewire-pulse.conf.d/system-socket.conf
content: |+
# Ansible managed
context.exec = [
{ path = "/bin/chgrp" args = "{{ music_audio_group }} {{ music_pulse_server }}" }
{ path = "/bin/chmod" args = "g+rwx,o-rwx {{ music_pulse_server }}" }
]
pulse.properties = {
server.address = [
"unix:{{ music_pulse_server }}"
]
}

View file

@ -1,4 +1,9 @@
---
- name: Import base
ansible.builtin.import_tasks:
file: base.yaml
tags:
- music_base
- name: Import mpd
ansible.builtin.import_tasks:

View file

@ -9,8 +9,7 @@ Type=simple
Restart=always
RestartSec=2s
ExecStart=/opt/librespot/target/release/librespot --name Trollibox --backend pulseaudio --volume-ctrl linear
Environment="PULSE_SERVER=/tmp/pipewire-pulse-socket"
Environment="XDG_RUNTIME_DIR=/run/user/0"
Environment="PULSE_SERVER={{ music_pulse_server }}"
User={{ music_librespot_user }}
[Install]

View file

@ -36,5 +36,5 @@ decoder {
audio_output {
type "pulse"
name "Pulse"
server "/tmp/pipewire-pulse-socket"
server "{{ music_pulse_server }}"
}