In this, part four of our ongoing series of how to setup a speedy and highly functional Linux environment, we'll cover getting our music integrated into our desktop!  We'll use Music Player Daemon (MPD) as our backend, and then setup ncmpcpp (a mouthful) as our frontend.  MPD operates as the server component of a server-client system and can be controlled over a network, allowing multiple clients to connect to the same music database.  ncmpcpp is a fast, ncurses based MPD client built in C++.

For this tutorial you'll need some tunes!  I've stored mine in ~/Music.

At the end of this tutorial, we'll have something that looks like this:

mpd and ncmpcpp running on Debian

Installing MPD:

To begin, let's install and configure MPD.   MPD's documentation takes special care to point out that Debian's packages are notorious for being out of date (no kidding) - however for ease of installation, we're going to use the repo version.  As always, we'll start by updating our software:

$ sudo apt update && sudo apt upgrade -y
$ sudo apt install mpd

Using the repo version has the added benefit of setting up the daemons correctly out of the box.  If we look at our services, we should see that both mpd.socket and mpd.service are enabled and running:

$ sudo systemctl list-unit-files | grep mpd && systemctl --state=running | grep mpd

mpd correctly installed

Our install looks good.  Now we need to configure MPD to serve our tunes!  Modify the global config at /etc/mpd.conf.  Enter the path to your Music folder.  For me this looks like:

$ music_directory "/home/miltiades/Music"

Save the changes and close the file.  Now we'll restart MPD:

$ sudo systemctl restart mpd.service


Installing ncmpcpp:

Great!  Now we'll install ncmpcpp from the Debian repos.  Though it's a bit stale too, it's still good!

$ sudo apt install ncmpcpp

Now we'll create and edit our ncmpcpp config file.  If you haven't started ncmpcpp yet, you'll need to create the folder too:

$ mkdir ~/.ncmpcpp && vi ~/.ncmpcpp/config

The following assumes the default mpd setup:

mpd_music_dir = "/home/militades/Music"
mpd_host = "localhost"
mpd_port = "6600"

Save at least those settings in the config file.  At this point we can run ncmpcpp via the command line and see the nice ncurses interface.

All that's left is to update the music database!  In ncmpcpp, press '4' to go to the browser view.  Press 'u' to perform a database update.  You should see whatever music you have in your music folder appear.  You can now navigate the music with the arrow keys.  Pressing 'enter' will add any selected music to the current playlist, and begin playing the first item selected.  Once you've chosen some music, press '1' to go back to the playlist view.

A useful ncmpcpp bindings quick reference can be found here.  Enjoy!

# Reads: 1550