Installing and Configuring MPD & ncmpcpp
I like to listen to music while I do homework or work on projects like those featured on this site, typically ah.fm. Waiting for Google Chrome to start and using the full resources it requires seems a bit wasteful and I thought it would be interesting to delve into the world of terminal-based music players so I installed MPD and ncmpcpp.
While I mostly listen to online streams, I also have a decent sized collection of mp3's that I have meticulously organized into folders (Albums by Artist/Artist Name/Album Name/song.mp3). I have had issues in the past with music players that do not respect folder organization, especially Google's Play Music Android app and iTunes. Most of my music is now bought as raw .mp3 files from the Google Play store (which is still great, only the Android app causes issues) or from an older iTunes library (thankfully post-iTunes-DRM).
I'll be following the Arch Wiki mpd page and ncmpcpp page for this install. To start off with, you'll need to install mpd and ncmpcpp: sudo pacman -S mpd ncmpcpp
Since I will be running mpd as a regular user, I'll be configuring it to run as my user (as opposed to a global system service, which must be started and is controlled by root).
For the configuration, copy mpd example configuration files to ~/.config/mpd/ (as below):
mkdir ~/.config/mpd && cp /usr/share/doc/mpd/mpdconf.example ~/.config/mpd/mpd.conf
Edit the newly-made ~/.config/mpd/mpd.conf to include (and change user and group entries):
user "username" group "usersgroup" bind_to_address "127.0.0.1" port "6600" # Required files db_file "~/.config/mpd/database" log_file "~/.config/mpd/log" # Optional music_directory "~/Music" playlist_directory "~/Music/Playlists" pid_file "~/.config/mpd/pid" state_file "~/.config/mpd/state" sticker_file "~/.config/mpd/sticker.sql" #Output to file, used for ncmpcpp visualization audio_output { type "fifo" name "Visualizer FIFO" path "/tmp/mpd.fifo" forma "44100:16:1" } #Output to ALSA audio_output { type "alsa" name "My Sound Card" mixer_type "software" }
NOTE: you may need to create these directories:
$ mkdir ~/Music/playlists $ touch ~/.config/mpd/{database,log,pid,state,sticker.sql}
MPD can now be started with 'mpd ~/.config/mpd/mpd.conf'
I added 'mpd ~/.config/mpd/mpd.conf' to my ~/.config/openbox/autostart to start it on login (really when an Openbox session is started, which happens right after login in SLiM for me, it could be added to ~/.profile or another autostart file instead, and even more auto start options are available in the Arch wiki page for MPD).
Now it's time to configure ncmpcpp to control mpd. If ~/.ncmpcpp/config doesn't exist you'll need to copy the sample config over:
mkdir ~/.ncmpcpp && cp /usr/share/doc/ncmpcpp/config ~/.ncmpcpp/config
Here's my ncmpcpp config as a reference. It's fairly standard, with a working FIFO pipe for visualization:
mpd_host = localhost mpd_port = 6600 #song_list_format = "{$3[%l]$9} {$5%a$9} {$6%t$9} %y %r %n {$5%b$9}" header_window_color = "cyan" volume_color = "red" state_line_color = "yellow" state_flags_color = "red" progressbar_color = "yellow" statusbar_color = "cyan" visualizer_color = green clock_display_seconds = "yes" visualizer_fifo_path = "/tmp/mpd.fifo" visualizer_output_name = "Visualizer FIFO" visualizer_sync_interval = "30" visualizer_in_stereo = "no" visualizer_sample_multiplier = "0.15" visualizer_type = "spectrum" (spectrum/wave) visualizer_look = "+┃"
Here's what that visualizer looks like: