One of my previous post detailed a program called “task warrior” which has made managing my todo list from the console easier. Now, another CLI program called ncmpcpp is satisfying my music needs very well. However, I had a hard time setting it up and getting it to detect any of my music files as the instructions on several forums were outdated. This article will get you up and listening using ncmpcpp in no time. Hope you enjoy using it as much as I do.

Installation

On Ubuntu/Debian

$ sudo apt-get install mpd mpc ncmpcpp

On Arch

$ sudo pacman -S mpd mpc ncmpcpp

mpd stands for music player daemon. It is a daemon(or server) running in the background and managing your music collection. ncmpcpp is a client for mpd.

Configuring Music Player Daemon (mpd)

One of the drawbacks of ncmpcpp is that it is a pain to configure and get it running correctly. However, the following instructions should hopefully make it a walk in the park.

Create the following file and directories for mpd

$ mkdir -p ~/.mpd/playlists
$ touch ~/.mpd/{database,log,mpd.conf,pid,state}

Now, you will need to populate the mpd.conf (mpd configuration file). Most installations of mpd will provide an example mpd configuration file which you can use/modify according to your needs.

On Ubuntu/Debian, the example mpd configuration file (compressed form) can be found at /usr/share/doc/mpd/examples/mpd.conf.gz. You will have to extract the file mpd.conf from mpd.conf.gz.

On Arch, the example configuration file is /usr/share/doc/mpd/mpdconf.example

Copy this example mpd configuration file to ~/.mpd and rename it to mpd.conf (if it is not already so).

# for Ubuntu/Debian
$ cp /usr/share/doc/mpd/examples/mpd.conf.gz ~/.mpd/
$ cd ~/.mpd
$ gunzip mpd.conf.gz

# for Arch
$ cp /usr/share/doc/mpd/mpdconf.example ~/.mpd/mpd.conf

Now, let us edit ~/.mpd/mpd.conf to suit our needs. Some of the most basic mpd configuration options that need to be enabled(uncomment in mpd.conf) are as below.

music_directory			"~/Music"	# path to your Music directory
playlist_directory		"~/.mpd/playlists"
db_file				"~/.mpd/database"
log_file			"~/.mpd/log"
pid_file			"~/.mpd/pid"
state_file			"~/.mpd/state"

audio_output {
	type		"alsa"
	name		"any name for your alsa device"
}

You can change “alsa” in the audio_output above to “pulse”, if you are using pulse audio.

You are now done configuring the Music Player Daemon(mpd). You can use mpd to listen to your favorite music from the command line. mpd supports several options to control your music collections (man mpd). If however, you are looking for a ncurses interface via ncmpcpp, read on…

Configuring ncmpcpp

Let us now configure ncmpcpp as a mpd client. Create the following files and folders.

$ mkdir ~/.ncmpcpp
$ touch ~/.ncmpcpp/config

~/.ncmpcpp/config is the ncmpcpp configuration file (the configuration file for the ncurses music player). There are several things that can be configured here that controls the ncmpcpp music player itself, but let’s keep it simple.

$ echo 'mpd_music_dir = "~/Music"' > ~/.ncmpcpp/config  # path to mpd music dir

And, that’s it… You have successfully configured ncmpcpp to work with mpd.

Now, all that’s left is to make mpd autostart on login. For this, you need to edit your distro specific autostart file.

Making mpd autostart on login

On Ubuntu/Debian, create a desktop file in ~/.config/autostart/. Let us name it mpd.desktop. Add the following lines to this file.

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Music Player Daemon
Comment=Server for playing audio files
Exec=mpd
StartupNotify=false
Terminal=false
Hidden=false

On ArchBang, edit the file ~/.config/openbox/autostart and append a single line as follows

$ echo "mpd" >> ~/.config/openbox/autostart

That’s it!!! The next time you restart your computer, mpd should already be running in the background, and you can launch ncmpcpp from the terminal anytime to listen to your fav music. The first time you launch ncmpcpp, you might not know all the keyboard shortcuts to manage you music collection. You are better of pressing ‘1’ to list all the keyboard shortcuts available. However, the following are some shortcuts you might need frequently, to get you rolling quickly.

q = quit ncmpcpp
u = update music database
1-10 = ncmpcpp screens # help, playlist, browse, search, etc
j,k = move down, move up
enter = add song to playlist and start playing the song
space = add song to playlist
d = delete song from playlist
c = clear entire playlist
s = stop playback
P = pause/continue playback
> = next track in playlist
< = previous track in playlist
f = seek forward currently playing track
b = seek backward currently playing track
+, - = increase/decrease volume
r = repeat entire playlist
y = repeat single track
z = play random song from playlist
# = toggle display of bitrate
/,? = find forward/find backward
, = find previous
. = find next
w = toggle find mode (normal search/wrapped search)
i/I = show song/artist info
L = toggle lyrics database
F = toggle fetching lyrics in the background
l = toggle display of lyrics