Ravi Sagar | Home | Blog

Install and configure mpd & ncmpcpp on Arch Linux

Table of Contents

I use the following configuration on my Thinkpad x220.

1 Install mpd and ncmpccp

sudo pacman -S mpd
sudo pacman -S ncmpcpp

2 mpd.conf file

mkdir ~/.config/mpd
cp /usr/share/doc/mpd/mpdconf.example ~/.config/mpd/mpd.conf

This is the content of my ~/.config/mpd/mpd.conf

music_directory		"/srv/public/sdcard1_4gb"
playlist_directory		"~/.config/mpd/playlists"
db_file			"~/.config/mpd/database"
log_file			"~/.config/mpd/mpd.log"
pid_file			"~/.config/mpd/pid"
state_file			"~/.config/mpd/state"
sticker_file			"~/.config/mpd/sticker.sql"
auto_update	"yes"
audio_output {
 type  "pulse"
 name  "mpd pulse-audio-output"

audio_output {
 type  "alsa"
 name  "mpd alsamixer-output"

audio_output {
 type   "fifo"
 name   "my_fifo"
 path   "/tmp/mpd.fifo"
 format "44100:16:2"

Don't install the mpd service. Run it under your user profile.

2.1 TODO Autostart mpd when dwm is started

3 Error: binding address and port already in use

Check which application is using the port

ss -a -p '( sport = 6600 )'

Then kill that process, it might be anothe mpd running.

4 Run mpd for troubleshooting errors

mpd --no-daemon --stdout --verbose

This will give you details of what went wrong in starting mpd.

5 ncmpcpp will run as it is

In my case I didn't do any configurations for ncmpcpp, it worked out of the box but it can also be customised if needed but we are bit adventurous, don't we.

cp /usr/share/doc/ncmpcpp/config ~/.config/ncmpcpp/config

This is how my ~/.config/ncmpcpp/config look like.

ncmpcpp_directory = ~/.config/ncmpcpp
lyrics_directory = ~/.config/mpd/lyrics
mpd_host = localhost
mpd_port = 6600
mpd_connection_timeout = 5
visualizer_data_source = /tmp/mpd.fifo
visualizer_output_name = Visualizer feed 
visualizer_in_stereo = yes
visualizer_type = spectrum
visualizer_look = ●▮
visualizer_color = 47, 83, 119, 155, 191, 227, 221, 215, 209, 203, 197, 161

6 ncmpcpp shortcuts

  • r: Toggle random mode
  • z: Toggle repeat mode
  • y: Toggle single mode, play only one song or not
  • >: Next track
  • <: Previous track
  • Enter: Play selected song
  • c: Clear playlist
  • e: Edit song
  • +: Increase volume
  • -: Decrease volume
  • f: Seek forward

7 Display current song using xsetroot

Make sure there is this line in your config file.

execute_on_song_change = "sh ~/.xsetroot.sh"

So the idea here is to call the ~/.xsetroot.sh when the song is changed and in this file there is a line to get the current playing song using ncmpcpp --current-song -q.

Great isn't it?