Music Setup - MPD, NCMPCPP, MPDScribble, Last.fm

I've been working on my local storage music playing setup for a little while and wanted to write it down so I could recreate it (and because a lot of stuff is not obvious.

I've got another post about checking trends in my music by year with exiftool and ruby over at Getting the years of your mp3 library.

The current layout this will produce looks something like this: a screenshot of a command-line based music player showing a playlist with 'Take the Power Back' by Rage Against the Machine highlighted, a green -> red linear spectrogram visualizer, and the album cover for the Rage Against the Machine album showing a black and white photo of Thích Quảng Đức self-immolating in protest of the South Vietnamese government of 1963

So the list of software I'm using is pretty small [but not as small as using Apple Music/Spotify + Last.fm]:

You can look at all these configs with some syntax highlighting but I'll talk a little about each: MPD Setup Files.

First thing I'll share is the mpd config file. One thing worth pointing out in there is I have two audio outputs configured, one for the music and another that is used by the visualizer. If you don't like the visualizer you don't need the fifo output. The other thing probably worth pointing out is I'm binding to a unix socket instead of a port. I found I couldn't get everything working without doing that, IIRC particularly mpdscribble didn't work.

Next we'll get into ncmpcpp config. NCMPCPP worked mostly as expected from the get-go. I had to set it up to use the unix socket above and I tweaked some visuals and behavior around volume changes and seek behavior. The line that makes the album cover change is this line:

execute_on_song_change = "~/.ncmpcpp/cover_obs.sh"

So let's look at cover_obs.sh. This is a *fairly* simple script that uses mpc mentioned above to pull currently playing file information like filename and artwork and spit that out into the /tmp directory. It also uses a funny default picture that motivates me to hunt down real artwork when I see it. But the art gets read from the mp3 file or from its directory (folder.jpg, cover.jpg, etm.) and then copied to a tmp directory. Also notable I have MUSIC_DIR set it my zsh config so I can use it here, but those $MUSIC_DIR could be hardcoded.

Now we have a file in a temp directory but nothing showing it. This is where fswatch comes in. So we have cover.sh and put_cover.sh that work in combination to display the cover and the currently playing song information next to it. I run the cover.sh script directly in the command line and it runs until I ^C it or my computer shuts off or whatever. put_cover.sh does a little work to clear its screen then uses imgcat and mpc to spit out the information we want.

The last piece is I use last.fm to track my music playing over time. So here's my mpdscribble.conf file. It expects a diretory at ~/.mpdscribble to do some logging and uses the aforementioned unix socket to communicate with mpd, but otherwise is uninteresting.

Once that's all configured we open up a new iterm window, split it vertically and split the right side horizontally. Then I run ncmpcpp in the big left window to do playlist display and library management and a smaller ncmpcpp window in the upper right with the spectogram - visualer hotkey is '8' and you change the active visualizer with spacebar. The bottom right is where I run cover.sh to see album art.

So this isn't perfect as setups go. One thing I couldn't get to work very well is lyrics lookup. Music.app absolutely crushes this problem and it's one of the killer features for music.app for me, but I've had enough problems with it otherwise I don't use it much any more. Another thing that would be neat is making the album art display have a link to discogs or something, but I haven't gone to the trouble yet. At some point I'll probably put the album year in there because I often want to know that. Another thing I couldn't get worked out was sending last.fm loves via a hotkey from ncmcpp. It's supposed to be possible but it was more complex than I wanted.

I changed a few things in my ncmpcpp keybindings but mostly it's stock. I have referenced the stock bindings file often trying to work things out. :D


Here's some stuff that was interesting and I couldn't get working, I haven't tried, or is just worth having a link to.


I use some other stuff that is related to all this but it's not part of the command-line.

Archive.org is an incredible resource for finding old music and exploring contemporary music, too.