[Solved] Starting MPD at startup (locally)

After installing and liking MPD on arch linux, I’ve decided to install it on Gentoo as well. Just like on arch, I’m running it as my local user and not on a seperate mpd account. However, when I want to start MPD using rc-service, it uses the config located at /etc/mpd.conf instead of the one found in my home folder, causing MPD to use an mpd music directory and a non-existent mpd user. All this means I can’t use openrc to start MPD at boot.
Is there a way to either start my local MPD using rc-service or some other way to start it at startup? Or should I just switch to a global MPD entirely? I’ve given this a thought, but both the arch and the gentoo wiki weren’t very clear on how to configure the mpd user (and the arch wiki also said this would require a workaround to work with pulseaudio)

update ~/.xinitrc to have it exec whatever script you want

While @reikoshea’s solution works, a better solution would be to use systemd.

https://wiki.archlinux.org/index.php/Music_Player_Daemon

If you look, specifically at the “Autostart with Systemd” section, it explains everything quite clearly.

you should be able to do this to enable mpd starting at boot: systemctl --user enable mpd

If you encounter issues running that, run through the following wiki page:

https://wiki.archlinux.org/index.php/Systemd/User

1 Like

Oh shit, my bad, I forgot to say that the new distro I want to use MPD on is gentoo, which doesn’t have systemd by default

Ah, that’s a bit more complex.

I’m not familiar with OpenRC. I can’t really help with that…

exec mpd

with whatever options you need in ~/.xinitrc will get it done.


P.S. If you want to use systemd, Gentoo does have a systemd stage3 if you’re not too married to your install. I’d tell you to install it, but I don’t want to rehash the whole debian init system war.

It’s also relatively easy to switch to systemd if you’d like to.

https://wiki.gentoo.org/wiki/Systemd

Alright, after being sick for a few days, I can finally return to this thread. I most likely won’t install systemd. That’s not because dislike it (in fact, I never really understood why people hate it so much), but because OpenRC is already installed and it works. Also since this is gentoo, I want to get used to OpenRC for now.

Also, the problem with starting mpd in ~/.xinitrc is that it will only start when x is started and sometimes I don’t start x at all.

Is there something like systemd’s --user option for OpenRC?

And it’s all solved now! I ended up setting up my mpd to run a as the mpd user (apperently I didn’t even have to create that one, mpd did that by itself). I then added an output to mpd.conf, that streams the audio to my user’s pulseaudio server (127.0.0.1). More on this can be found here. And voilà, I can now start mpd at boot using openrc, without starting a graphical session

1 Like

Thanks for updating the thread, glad you were able to sort it out yourself.

Feel free to mark the thread title as solved.