-
Notifications
You must be signed in to change notification settings - Fork 576
Running as a service
Many distributions use systemd to manage both system services an user services.
librespot
can be run as a service using systemd
.
contrib/librespot.service
can be used an example to write your own service unit file or can be installed as-is into /usr/lib/systemd/system/
.
This will allow running librespot as a system-wide service permanently by
enabling it:
systemctl enable --now librespot
This is the recommended approach for embedded devices. Note that only root
can manage this service.
(as of librespot 0.3.0)
contrib/librespot.user.service
can be used an example to write your own service unit file or can be installed as-is into /usr/lib/systemd/user/
.
This will allow running librespot as a user service which can be controlled
without privileges, and is bound to the currently logged in user.
systemctl --user enable --now librespot
This is the recommended approach for desktops, especially for shared devices where not all users will have root privileges and to avoid compatibility issues with PulseAudio.
Running librespot in the background and on boot can be done rather easily if using linux using Supervisor.
You may need to edit these slightly for other distributions.
For Ubuntu/Debian:
Install supervisor using apt.
sudo apt update
sudo apt install supervisor
Create the supervisor configuration file.
sudo nano /etc/supervisor/conf.d/librespot.conf
In there paste the following (edit the options as required):
[program:librespot]
command = /path/to/librespot --name "Speaker"
redirect_stderr = true
stdout_logfile = /var/log/librespot.log
Finally run the following to restart supervisor.
sudo supervisorctl update
If you are having problems have a look at the log file. To restart after changing config:
sudo supervisorctl reread
sudo supervisorctl restart librespot
and to check the status:
sudo supervisorctl status
For a full list of supervisor options see here.
In case you would like to use the pulseaudio backend, you will need to specify the XDG_RUNTIME_DIR environment variable for librespot to connect to the pulseaudio server. For example, add the following line to /etc/supervisor/conf.d/librespot.conf:
environment=XDG_RUNTIME_DIR="/run/user/1000"
You might have to edit 1000 to the id of your user.