music/librespot: Various tweaks

* Use pulseaudio backend
* Run as separate librespot user
* Use linear volume mixer
This commit is contained in:
polyfloyd 2025-05-14 19:57:30 +02:00
parent 301529271d
commit 43075d27fe
4 changed files with 22 additions and 15 deletions

View file

@ -1,2 +1,5 @@
music_audio_user: audio
music_audio_group: audio
music_librespot_user: librespot
music_mqtt_mpd_volume: bitlair/music/space/volume

View file

@ -8,13 +8,13 @@
state: restarted
daemon_reload: true
- name: Rebuild librespot
- name: rebuild librespot
ansible.builtin.command:
cmd: /root/.cargo/bin/cargo build --release --features jackaudio-backend
cmd: /root/.cargo/bin/cargo build --release --features pulseaudio-backend
args:
chdir: /opt/librespot
- name: Restart librespot
- name: restart librespot
ansible.builtin.systemd:
name: librespot
state: restarted

View file

@ -1,8 +1,11 @@
---
- name: Install dependencies
ansible.builtin.apt:
name: libjack-jackd2-dev
state: present
- name: Create librespot user
user:
name: "{{ music_librespot_user }}"
system: true
home: /var/lib/librespot
groups:
- "{{ music_audio_group }}"
- name: Clone librespot source
ansible.builtin.git:
@ -11,8 +14,8 @@
dest: /opt/librespot
accept_hostkey: yes
notify:
- Rebuild librespot
- Restart librespot
- rebuild librespot
- restart librespot
- name: Install service file
ansible.builtin.template:
@ -21,7 +24,7 @@
owner: root
group: root
mode: 0644
notify: Restart librespot
notify: restart librespot
- name: Enable Librespot
ansible.builtin.systemd:
@ -29,3 +32,5 @@
state: started
enabled: true
daemon_reload: true
- meta: flush_handlers

View file

@ -3,16 +3,15 @@
[Unit]
Description=Spotify through Librespot
After=network.target
Requires=jackd.service
[Service]
Type=simple
Restart=always
RestartSec=2s
ExecStart=/opt/librespot/target/release/librespot --name Trollibox --backend jackaudio
User={{ music_audio_user }}
Group={{ music_audio_user }}
AmbientCapabilities=CAP_IPC_LOCK,CAP_SYS_NICE
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"
User={{ music_librespot_user }}
[Install]
WantedBy=multi-user.target