User:Lcarsos/Music Player Daemon
Autostart with systemd
In recent versions of systemd (It seems to start at 207) the syntax for starting a service as a specific user changed. In 206 and before a user specific service could be enabled by systemctl --user enable service_name.service
. The modern way is to call systemctl enable service_name@username.service
.
The mpd package has not been updated. It provides a service file in /usr/lib/systemd/system/mpd.service
. This file will work well for a global installation of mpd, but not for specific user instances. There is a symlink to that file at /usr/lib/systemd/user/mpd.service
, but that is not useful.
Either make a copy of the service file to /etc/systemd/system/mpd@.service
or move the file to /usr/lib/systemd/system/mpd@.service
.
The configuration file ~/.mpdconf
is expected to exist (otherwise the global /etc/mpd.conf
is used). You should not use the user
and group
variables in the configuration file.
~/.mpdconf
, copy /usr/lib/systemd/system/mpd.service
to ~/.config/systemd/user/mpd.service
and edit it to contain the path of your configuration file:
~/.config/systemd/user/mpd.service
... ExecStart=/usr/bin/mpd --no-daemon /path/to/your/mpd.conf ...
All you have to do is enable and start the user service:
$ systemctl --user enable mpd $ systemctl --user start mpd