Mpd Client For Mac

Ario is a GTK2 client for MPD (Music player daemon). The interface used to browse the library is inspired by Rhythmbox but Ario aims to be much lighter and faster. It runs on various Unixes (Linux, OpenBSD, Mac OS X.) and Microsoft Windows. From the website: “Music Player Daemon (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol.” Wikipedia has a more comprehensive description.

Another Look At Perl 6Making SSH_AUTH_SOCK Work Between Detaches in Tmux

I use a Macbook Pro for my work at Booking, and I use music (or sometimes background noise) to avoid distractions while at work. However, I'm not a terribly big fan of iTunes; I much prefer the simplicity of MPD. My client of choice for MPD is Practical Music Search (pmus), which is curses-based and provides a nice shuffle feature. However, I want to avoid going back-and-forth between pmus and my work when I want to pause or skip tracks, so I managed to repurpose OS X's media keys to manipulate MPD and pmus. Here's how I did it.

By default, OS X responds to the media keys by starting up iTunes (if it's not running) and forwarding the command on to iTunes. Removing this default behavior isn't obvious, but once you discover the solution, it's quite easy. I ended up using KeyRemap4MacBook; it requires a reboot after installation, but after it's done installing, you only need to open it in System Preferences and tell it to remove the behavior for the media keys.

Unfortunately, OS X doesn't allow you (to my knowledge) to execute arbitrary command lines when you press a key. Fortunately, Quicksilver does, at least in the form of Applescript. So I saved the following snippets to their own Applescript files:

The scripts for the next/previous song may look a little different than expected; it's because for the next song, I often rely on pmus' shuffle feature. Simply sending the 'next' command to MPD would not populate the next song from the shuffle, so I needed to use a workaround using tmux. This also means I need to run pmus from within a tmux session named 'pmus'.

Creating keybindings for the scripts

Mpd Client For Mac

Now that those are done, open Quicksilver's preferences, go to the 'Triggers' tab, and add a hotkey for each script. You can simply drag and drop the script from Finder into Quicksilver for this.

That was the last step! Enjoy your pmus-bound media keys!

-Rob

Published on 2012-07-26Please enable JavaScript to view the comments powered by Disqus.

Mpd Music Server

Some time ago I detailed a simple hack for making MPD work with AirPlay. I considered it just that, a simple hack. I wanted something better even then, and my recent revelation that MP3 sucks just made it all the more necessary. I also hated having to use iTunes for my special music. So at last I now present the best way I’ve found to make MPD work with AirPlay on the Mac.</p>

This solution won’t suit everyone. The command line client works best, in other words you do things by typing commands instead of navigating through menus. They do make an unmaintained Mac client but I haven’t played with that yet. You can also get clients for your iPhone, iPod, or iPad. It’ll also cost you $25. That said, it works beautifully.

First, you need to install MPD. If you haven’t already, install XCode and MacPorts. Once installed, go to the terminal and type “sudo port install mpd mpc”. Enter your administrator password and it will install the daemon and a command line utility called mpc which comes in handy if you need to debug this, which you will.

Now, create MPD’s configuration file. It comes with one in /opt/local/etc/mpd.conf, but I had to alter a few things. Either back that one up and overwrite it or just create a file called ~/.mpdconf. Put in the following contents:

</span>music_directory “~/Music”
playlist_directory “~/.mpd/playlists”
db_file “~/.mpd/database”
pid_file “~/.mpd/pid”
state_file “~/.mpd/state”
sticker_file “~/.mpd/sticker.sql”
port “6600”
auto_update “yes”
audio_output {
type “ao”
name “My Mac Device”
mixer_type “software”
}

Mpd

Now create your user’s mpd directory by typing “mkdir ~/.mpd”. This should complete MPD’s setup.

This configuration file has some interesting features. It indexes your Music directory. Imagine iTunes without the mess of iTunes. It also uses the AO audio output. Once again xiph.org comes to the rescue with their cross-platform audio library. The default Mac audio output jittered.

You should test your setup at this point. Type “mpd” at a terminal prompt and the daemon should start. It will index your music the first time you run it. Type “mpc” to see the status. Hopefully you will see something like this:

Updating DB (#1) …
volume: 100% repeat: off random: off single: off consume: off

Mpd Client Macos

Music

If it can’t connect then something went wrong. Check that you’ve done everything properly so far.

You may want to have a look at MPD’s and MPC’s manual pages. Just type “man mpd” for the daemon and “man mpc” for the client. You will want to learn the client’s commands. Feel free to try adding some music or a radio stream with “mpc add” and playing it with “mpc play”. “mpc stop” stops playback. To kill the MPD process, just type “mpd –kill”. You should do this before moving on.

Assuming that worked, we can now move on to getting it working with AirPlay. You will need to download and purchase AirFoil. This awesome little program will pipe any audio over AirPlay. As a bonus, it will select the audio output to use. I love it!

Once you get it going you will want to tell it to launch MPD. This part tripped me up. I emailed their excellent tech support and they suggested using option-click and selecting MPD’s process. This works, but unfortunately VoiceOver doesn’t handle option-clicking very well. I had to find another solution.

Mpd Client For Mac

I decided I had to get AirFoil to run MPD. I tried launching MPD directly but it wouldn’t work. Then I got the idea to make a wrapper script to launch MPD. I whipped one up but that wouldn’t work either. It turns out I had to turn the shell script into an application bundle. Fortunately, this awesome little utility called Appify does just that.

Mpd Client For Mac Free

I used that program to convert my shell script to an application bundle and it works like a charm. Simply download this file and unzip it into your /Applications directory. Now choose MPD Launcher from AirFoil and there you go!

Mpd Client

If you’ve followed everything then you should having a working MPD setup streaming its audio over AirPlay and over your chosen sound card. What a bargain! This really does provide the best of both worlds for those who like the command line but who also want AirPlay. You can also get mPoD for the iPhone/iPod and mPaD for the iPad, which will let you control this awesome setup from your iDevice. This gives a truly luxurious touch. You just can’t lose!