July 21, 2010

Running MPD on OSX

After finally getting fed up and giving iTunes the boot, I got round to making MPD work on my Mac. and unfortunately, apt-get install it ain’t!

First step is to actually get hold of and install mpd, if you’re using sensible and using homebrew that’s as easy as:

brew install mpd

Which will pull in all of the required dependancies and compile them all for you. Then comes the mpd config file. This is all pretty standard stuff, you can adapt from the standard and massively verbose example included with the mpd sources. Mine lives at /usr/local/Cellar/mpd/0.15.9/share/doc/mpd/mpdconf.example. The stuff you need to care about is:


mixer_type "software"

Make sure these paths are all writeable by the user that you intend to run mpd as. In my case, I run mpd as the mpd user, and I made the mpd user and my normal user account members of group mpd.

What this amounts to is a music and playlist directory that the mpd user can read from and that I can add songs to. If you run a multi user system it’s probably a good idea to put this somewhere outside of your home dir.

A special point regarding the mixer_type line: I have found this necessary when running on Snow Leopard to avoid mplayer crashing hard when trying to skip playing tracks, but as is normal with these things YMMV.

Once this has been set up you should be able to start mpd with

mpd --create-db

and watch it chug away for a while depending on how much music you have.


I use the excellent Theremin, which is an OSX native MPD client and does the job admirably. If that’s not your style there are an excellent array of decent mpd clients out there.


Last fm Scrobbling is acheived by the use of the lastfmsubmitd daemon, and it’s built in client lastmp. It’s dead easy to set up. Clone the sources from Github and follow the instructions in the INSTALL file. The client scrobbler lives inside the contrib folder of the checkout.

I installed lastfmsubmitd to /usr/local/bin and created it’s config file, and then simply copied the contrib/lastmp script to /usr/local/bin.

One gotcha if you’re not familiar with running Python stuff (I’m not) is that lastmp will bail out complaining it can’t import libmpdclient2. this is easily fixed with:

easy_install py-libmpdclient2

which will ramble on about installing eggs, I guess these are pythons equivalent of gems.

Both of these daemons apparently need to be running to actually make scrobbling happen so I normally wrap these up in @/usr/local/bin/music_starter@, which looks like

  #! /bin/sh
  /usr/local/bin/mpd && \
  /usr/local/bin/lastfmsubmitd && \

Tying it all together

You can start the whole kit and caboodle on boot by creating the following plist file and adding it to launchctl:

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">


I put this in /Library/LaunchDaemons/com.eightbitraptor.mpd.plist. Add it to launchd and start it like this:

sudo launchctl load -w /Library/LaunchDaemons/com.eightbitraptor.mpd.plist
sudo launchctl start com.eightbitraptor.mpd.plist

And Job done! Now you too can get rid of stinking iTunes. Now all that’s left is to find something comparable to “mp3tagedit”: