A simple guide to set up mpd with ncmpcpp

There are already a lot of nice music players for Linux, from powerhouse players with many features like Banshee, Rhythmbox, Clementine or Nuvola or light-weight simple music players like Deadbeef or Quod Libet. However, my favorite is always mpd with ncmpcpp. MPD is an audio player that has a server-client architecture. MPD runs in the background as a daemon, manages playlists and a music database, and uses very few resources. And ncmpcpp is a text-based client for MPD originated from Ncmpc (hence it's call Ncmpc plus plus). Ncmpcpp has an UI very similar to ncmpc's one, but it provides new useful features such as support for regular expressions in search engine,ability to sort playlist, local filesystem browser, song lyrics, extended song format, items filtering, fetching artist's info from last.fm, tag editor, and many other minor functions. Ncmpcpp is very light weight and easy to use and highly customizable.

mpd ncmpcpp in Arch Linux

Setting ups mpd with ncmpcpp can be quite challenging for those who are new to Linux so I will make this guide absolutely newbie-friendly and I guarantee you that will work in every Linux distro.

1 - Installing mpd, mpc and ncmpcpp

Since these packages are in the repo of all the popular distro, the installing process is a piece of cake.

If you use Arch Linux, run the following command:
 sudo pacman -S mpd mpc ncmpcpp  

if you use Ubuntu or other Debian based distros, run this command:
 sudo apt-get install mpd mpc ncmpcpp  

2 - Configuring mpd

To make mpd work with a local user, you need to create a /home/username/.mpd folder first
 mkdir .mpd  
Then create a playlists folder
 mkdir -p ~/.mpd/playlists  
Then create the required files that you will need to include in the mpd config file
 touch ~/.mpd/{mpd.db,mpd.log,mpd.pid,mpdstate}  

Next, you need to create the config file for mpd, use whatever text editor you prefer to create it. I will use vim here:
 vim ~/.mpd/mpd.conf  
If you are using alsa as the sound device, here is what you will put into the mpd.conf file.
 music_directory "/your/music/folder"  
 playlist_directory "/home/username/.mpd/playlists"   
 db_file      "/home/username/.mpd/mpd.db"  
 log_file      "/home/username/.mpd/mpd.log"  
 pid_file      "/home/username/.mpd/mpd.pid"  
 state_file     "/home/username/.mpd/mpdstate"  
 audio_output {  
     type  "alsa"  
     name  "whatever name you want"  
 }  

If you're using Ubuntu or Linux Mint, alsa will be replaced by pulse, therefore the mpd.conf will be like that (just change "alsa" into "pulse"):
 music_directory "/your/music/folder"  
 playlist_directory "/home/username/.mpd/playlists"   
 db_file      "/home/username/.mpd/mpd.db"  
 log_file      "/home/username/.mpd/mpd.log"  
 pid_file      "/home/username/.mpd/mpd.pid"  
 state_file     "/home/username/.mpd/mpdstate"  
 audio_output {  
     type  "pulse"  
     name  "whatever name you want"  
 }  

3 - Configuring ncmpcpp and run mpd with ncmpcpp

To start mpd, just type "mpd" in the terminal and mpd will run in the background and you can stop mpd by running the command mpd --kill or pkill mpd. To run ncmpcpp for mpd, you have to start mpd first. Here is a simple script I use to start mpd with ncmpcpp in my archlinux machine ( note: replace terminator with your prefered terminal client)
 #!/bin/bash  
 mpd  
 terminator -e ncmpcpp  

To configure ncmpcpp, you need to create a config file for ncmpcpp:
 vim ~/.ncmpcpp/config  

To get ideas about how to customize ncmpcpp, the best place you should visit is this thread about ncmpcpp configs and screenshot on the ArchLinux forum.

And here is my config file, you can copy it into your config file if you like it. The screenshot below is how it looks in the gnome terminal of Linux Mint 12.
mpd with ncmpcpp in Linux Mint

When you first start ncmpcpp, what you see is but an empty playlist. However, you will see the top menu bar showing you the different modes of ncmpcpp. If you’re new to the key-bindings or ncmpcpp, hit F1 or ’1′ to get into help page. Here is the list of options of ncmpcpp:
 Up k    : Move Cursor up  
     Down j   : Move Cursor down  
     Page Up   : Page up  
     Page Down  : Page down  
     Home    : Home  
     End     : End  
     Tab     : Switch between playlist and browser  
     1 F1    : Help screen  
     2 F2    : Playlist screen  
     3 F3    : Browse screen  
     4 F4    : Search engine  
     5 F5    : Media library  
     6 F6    : Playlist editor  
     7 F7    : Tag editor  
     0 F10    : Clock screen  
   Keys - Global  
  -----------------------------------------  
     s      : Stop  
     P      : Pause  
     >      : Next track  
     <      : Previous track  
     f      : Seek forward  
     b      : Seek backward  
     Left -   : Decrease volume  
     Right +   : Increase volume  
     t      : Toggle space mode (select/add)  
     T      : Toggle add mode  
     |      : Toggle mouse support  
     v      : Reverse selection  
     V      : Deselect all items  
     A      : Add selected items to playlist/m3u file  
     r      : Toggle repeat mode  
     Z      : Shuffle playlist  
     i      : Show song's info  
     I      : Show artist's info  
     L      : Toggle lyrics database  
     l      : Show/hide song's lyrics  
     q Q     : Quit  
linux tips and tricks