placeholderConfiguring Music Player Daemon (MPD) and Clients on macOS

Configuring Music Player Daemon (MPD) and Clients on macOS

This article introduces Music Player Daemon (MPD) and its clients MPC and RMPC for a lightweight, customizable music playback experience on UNIX.

Music Player Daemon

Setup MPD

After installing, you can create the config directory and start/stop the mpd service with the commands below. Following the XDG Base Directory Specification, I keep my mpd config under ~/.config/mpd/.

MPD is an audio player that has a server-client architecture. MPD plays audio files, organizes playlists and maintains a music database, all while using very few resources. In order to interface with it, a separate client is needed.

# The default config dir is ~/.mpd# I prefer use $XDG_CONFIG_PATH to store mpd config;mkdir ~/.config/mpdmkdir ~/.config/mpd/playlists# Start/Kill Mpdmpd ~/.config/mpd/mpd.confpkill mpd

The MPD config[1] allows multiple audio_output entries. Adding a fifo output lets you pair it with cava for music visualization.

~/.config/mpd/mpd.conf
music_directory    "~/Music/CloudMusic"bind_to_address    "127.0.0.1"port               "6600"audio_output { type "osx" name "CoreAudio" mixer_type "software"}audio_output { type "fifo" name "my_fifo" path "/tmp/mpd.fifo" format "44100:16:2" auto_resample "no" use_mmap "yes"}

MPC

MPC[2] provides a minimalist CLI to MPD that covers basic playback needs. For example, the commands below switch tracks, show what’s currently playing, and search songs by ID3Tags[3].

MPC Examples
# Skip to the next track$ mpc nextRadiohead - Pyramid Song[playing] #7/50   0:00/4:49 (0%)volume: 96%   repeat: off   random: off   single: off   consume: off# Show the currently playing track$ mpc currentRadiohead - Pyramid Song# Search music files by ID3Tags$ mpc search artist radiohead摇滚/Radiohead - Pyramid Song.mp3摇滚/Radiohead - How Can You Be Sure?.mp3...摇滚/Radiohead - Fake Plastic Trees.mp3摇滚/Radiohead - Black Star.mp3

You can build scripts on top of mpc’s interface, or integrate it into status bars like SketchyBar or i3status.

After mpd starts, the play queue is empty by default. Run the following to add all music files to the queue:

mpc clearmpc listall | mpc add

RMPC

If you want a richer TUI experience, try RMPC, an MPD client written in Rust that is feature-rich and highly configurable.

Rmpc Features

  • Album cover art display if your terminal supports either of Kitty, Sixel, Iterm2 protocols, or via ueberzuggpp
  • Cava integration for music visualisation
  • Support for synchronized lyrics
  • Ability to play music from YouTube
  • Configurable (T) UI
    • Configure what information (if any!) is displayed in the header
    • Configure what columns are displayed on the queue pane
    • Completely customize what tabs are rendered and mix and match their content
    • Create any color theme you want
    • Every keybind can be changed, vim-like by default
  • Ranger/LF-like three-column browser through your music library
  • Basic playlist management
  • Support scripting through basic CLI mode and script hooks
  • Remote control - Send commands to running rmpc instances (useful for window manager integration).

Here is a preview of my configured RMPC interface:

rmpc_preview
rmpc_preview

Two features worth calling out are RMPC’s lyrics and visualization support.

According to Lyrics fetching from the song file · Issue #287, RMPC does not yet support reading lyrics tags embedded in mp3/flac files. To display lyrics, you need separate lrc files.

The tooling for this is mature. Software like MusicTag for Android makes batch processing easy.

To add visualization to rmpc:

  1. Install cava, and add a fifo output to the mpd config (see the mpd config section above)
  2. Enable the cava feature in the rmpc config
  3. Enable the cava display in the Queue tab (or any other tab you prefer)
  4. Configure the cava theme

rmpc uses RON (Rusty Object Notation) as its configuration language, which takes some learning. I won’t go into my configuration details here; see my config repo[4] for reference.

Tweaks

Now Playing for MPD on macOS

On macOS, mpd is not a now-playable app[5]: while playing music, the macOS now-playing widget shows no information about the current track, and the media keys don’t work either.

The fix:

-. Install mpd-now-playable

brew install pipxpipx install mpd-now-playable

-. Once installed, just run mpd-now-playable. The executable lives in ~/.local/bin.

1029_mpd_nowplaying
1029_mpd_nowplaying

1029_mpd_fixed
1029_mpd_fixed

  1. Check mpd.conf — Music Player Daemon 0.25~git documentation for detailed documentation. ↩︎

  2. Music Player Client, mpc - Music Player Daemon ↩︎

  3. ID3 - Wikipedia ↩︎

  4. Visit GitHub for my Mpd Configs & Rmpc Configs ↩︎

  5. Becoming a now playable app | Apple Developer Documentation ↩︎