Setting up MPD and Ncmpcpp in Arch Linux
Just to echo Linux.com’s starting line in “CLI audio players for Linux”: What would life be without music? That’s the number 1 thing every self-respecting 21st Century man does in his free time—lip-sync to Britney Spear’s mp3 playing off their computer at eardrum shattering volume. Alsa is also the first thing I install in Arch Linux. Not X, not openssh or anything fancy. Just a good command line audio player with the ability to play mp3, ogg and streaming Internet radio.
Even if you’re running some instance of X like: Gnome, KDE, Xfce or some other window manager, there are reasons why you might want to use a command line audio player even though there are GUI audio players like Audacious, Rhythmbox and Amarok:
- You cannot or will not install X :D
- You are using an old computer with limited resource
- You’re crazy
The last point doesn’t really count as a reason, but I have been trying to learn the Linux command line for the longest time. Even though my 4 year old Toshiba laptop with 1Gb RAM can do Gnome or KDE with relative ease, I’m challenging myself to make my way around Linux using only the command line—for education purposes—not as if I’m such a whiz with an obscure OS like Linux. :p
Ncmpcpp is the frontend for MPD featuring a ncurses TUI(Text User Interface). Instead of typing something like:
archer@oldlappie ~ # mpc search artist 'Lisa Ono' | mpc add
archer@oldlappie ~ # mpc play
You can have something like the image below to easily manage your playlist, browse, add, play, delete and even download lyrics for singing along when your favorite song is playing.
Lyrics window for your sing-along pleasure:
Even if you’re a little lost when you launch ncmpcpp for the first time, help is just a keystroke away:
MPD has features other than the more obvious ones I’ve listed above. I installed MPD on Arch Linux, so this post contains notes on how I got MPD and ncmpcpp rolling on my chosen distro.
MPD installation notes
1. Installing mpd, mpc and ncmpcpp
2. Configuring mpd
3. Starting mpd and playing from ncmpcpp
1. Installing mpd, mpc and ncmpcpp
Install using Arch Linux’ package manager(pacman) as root:
root@oldlappie ~ $ pacman -S mpd mpc ncmpcpp
That’s it! easy peasy, japaneasy.
2. Configuring mpd
create your mpd directory: /home/[user]/.mpd
archer@oldlappie ~ # mkdir .mpd
Copy mpd.conf.example from /etc to your .mpd directory:
archer@oldlappie ~ # cp /etc/mpd.conf.example .mpd/mpd.conf
Edit /home/[user]/.mpd/mpd.conf using your favorite editor. I’ll be using vim:
archer@oldlappie ~ # vim .mpd/mp.conf
uncomment and make your mpd.conf file reflect as below:
music_directory "/home/[user]/music" # where you store your music
playlist_directory "~/.mpd/playlists"
db_file "~/.mpd/mpd.db"
log_file "~/.mpd/mpd.log"
error_file "~/.mpd/mpd.error"
pid_file "~/.mpd/mpd.pid"
state_file "~/.mpd/mpdstate"
user "[user]"audio_output {
type "alsa"
name "My ALSA Device"
}
Make the ‘playlist’ directory as specified in your mpd.conf:
archer@oldlappie ~ # mkdir .mpd/playlists
That’s about it for configuring mpd for a local user. We’ll have to update mpd’s database before it’ll read, display and play the audio files in your directory.
archer@oldlappie ~ # mpd --create-db
That will start your mpd and you can test if it’s working by adding and playing songs with mpc:
archer@oldlappie ~ # mpc search artist 'Lisa Ono' | mpc add
archer@oldlappie ~ # mpc play
Lisa Ono - I Wish You Love
[playing] #47/62 0:01/3:49 (0%)
volume: 85% repeat: on random: on single: off consume: off
archer@oldlappie ~ #
Ncmpcpp doesn’t require too much configuration, but if you’re going to use ncmpcpp’s in-built tag editor, add your music directory to ‘~/.ncmpcpp/config’.
mpd_music_dir = "/home/[user]/music"
Start ncmpcpp by entering ‘ncmpcpp’ in the command line. That should show you an empty playlist. Top most menu bar will should you the different mode ncmpcpp is capable of. If you’re unsure of the key-bindings in ncmpcpp, hit F1 or ‘1′ to get into help page. Minimal commands you should know.
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
Hope you will enjoy using mpd and ncmpcpp as a low footprint audio player.