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_user: audio
music_audio_group: audio
music_librespot_user: librespot
music_mqtt_mpd_volume: bitlair/music/space/volume music_mqtt_mpd_volume: bitlair/music/space/volume

View file

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

View file

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

View file

@ -3,16 +3,15 @@
[Unit] [Unit]
Description=Spotify through Librespot Description=Spotify through Librespot
After=network.target After=network.target
Requires=jackd.service
[Service] [Service]
Type=simple Type=simple
Restart=always Restart=always
RestartSec=2s RestartSec=2s
ExecStart=/opt/librespot/target/release/librespot --name Trollibox --backend jackaudio ExecStart=/opt/librespot/target/release/librespot --name Trollibox --backend pulseaudio --volume-ctrl linear
User={{ music_audio_user }} Environment="PULSE_SERVER=/tmp/pipewire-pulse-socket"
Group={{ music_audio_user }} Environment="XDG_RUNTIME_DIR=/run/user/0"
AmbientCapabilities=CAP_IPC_LOCK,CAP_SYS_NICE User={{ music_librespot_user }}
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target