Once before I had installed MPD, and once before I really liked it. But as always with updates something had to be stuborn. I honestly hadn’t noticed the breakage until I tried to play some music recently with Sonata. I have Sonata configured as to search for new audio on every load up. This time I had added new audio to the music folder and this time I got zip – the playlist showed, well… empty. I looked into
/var/lib/mpd/database and sure enough it the listing blanked.
It had been awhile since I installed the Music Player Daemon originally, and though I usually take notes of the process i didn’t’ remember to and I was at a loss at how to repair it. With the Gentoo LInux Wiki down last week, I was at a total loss.
The Music Player Daemon for those of you who haven’t tried it, heard it, is exactly as it states: a constant running process on your computer that’s able to play music. I should not say “your” however because many people use MPD on server and listen to audio over a network. What I’m talking about here is setting up MPD as a local daemon as opposed to a remote daemon. Why do this? MPD provides an absurdly low CPU usage and since it is continually running near to zero startup times. Using MPD as a local daemon as opposed to the remote daemon, though both processes will be similar, is different enough. I’ll start at the very beginning.
This is what I had forgotten so many months ago. MPD looks at it’s configuration files and requires them to belong to the audio group and also to the owner listed in the configuration file. I saw this as odd as I failed to see why a daemon needs permissions since it runs as root. This is reasonable I learned if you use MPD as it was originally intended: as a remote daemon. An MPD server would create a user “mpd” and hence have all the proper settings to begin distributing sound. I might argue that MPD is probably installed as a local daemon more often then it is as a remote one…
Verify these exist:
The database will need to be created.
echo > /var/lib/mpd/database
As well as a pid file (I’ll talk about that in a bit.)
echo > /var/run/mpd/mpd.pid
All these files and folders must have the correct permissions. They need belong to owner:group – youruser:audio.
chown user:audio /var/lib/mpd/* /var/log/mpd/* /var/run/mpd/*
Now we need to tell MPD where to find your audio directory
ln -s /home/user/My\ Audio
Setting the Configuration
There a few details here that will need to be set to have MPD work nicely
To begin make sure info of the pid file is commented out, this is necessary to the init-script to close correctly.
Now replace your username. Since we won’t be running MPD as a separate user we need to set “mpd” for our own.
Configure audio output if you know all the details otherwise the driver settings will be used (which is what you want for most cases.).
Create the Music Database
Now we should have all the settings need to build a proper database.
Start the Daemon
Add the daemon to the run-level
rc-update add mpd default
Setting a pid file as a local daemon is little tricky. MPD wants a Personal ID file which is important to close MPD., whether it’s needed or not… In my personal opinion this is an over-site of MPD as it does not create a new pid on initializing but requires one to shutdown. To add the the dilemma, MPD will delete pid on shutdown, meaning that we will have to make one each time MPD is started. The only solution I’ve found to reasonably fix this is to edit the boot script.
And add in the checkconfig section:
echo > /var/run/mpd/mpd.pid
chown user:audio /var/run/mpd/mpd.pid
Picking a Client
I’ve heard of MPD using a
~.mpdconf. Has anyone tried this? How does it work?