Debian

How to configure mpd and ncmpcpp on Linux

Configure mpd and ncmpcpp on Linux: Music Player Daemon (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol. In order to interact with mpd, a client program is needed. Most commonly used client Applications being:

Original content from computingforgeeks.com - post 1242
  1. ncmpcpp : Almost exact clone of ncmpc with some new features written in C++ (tag editor, search engine)
  2. ncmpc: Ncurses client for mpd
  3. mpc – Command line user interface for MPD server

Above mentioned applications are console based.

In this guide, I’ll take you through steps to install and configure mpd and ncmpcpp on Linux. Installations will be based on Ubuntu and Arch Linux. If you are a MacOS User, have a look at Install and configure mpd and ncmpcpp on MacOS

Install mpd on Linux

As we kick off on how to configure mpd and ncmpcpp on Linux, we’re starting with the installation process.

Install mpd on Arch Linux:

Mpd for Arch Linux is available on both official repositories and AUR:

sudo pacman -Sy mpd --noconfirm

To get latest development version, use AUR. Check our guide on AUR:

$ yay -S --needed --noconfirm mpd-git
OR
$ yaourt -S mpd-git

Install mpd on Ubuntu:

For Ubuntu, it is also available on official repositories:

sudo apt update
sudo apt install mpd

For other distributions, have a look at official installation guide:

Configure mpd

Now create directories needed by mpd. Lets create default configurations directory and playlist directory:

mkdir -p ~/.mpd/playlists/

Create mpd.conf file inside ~/.mpd directory. The content can be modified to your liking:

vim ~/.mpd/mpd.conf

Add the following content:

 bind_to_address "127.0.0.1"
 #bind_to_address "~/.mpd/socket"
 music_directory "~/Music"
 playlist_directory "~/.mpd/playlists"   
 db_file      "~/.mpd/mpd.db"  
 log_file      "~/.mpd/mpd.log"  
 pid_file      "~/.mpd/mpd.pid"  
 state_file     "~/.mpd/mpdstate"  
 audio_output {  

     type  "pulse"  
     name  "pulse audio"
     device         "pulse" 
     mixer_type      "hardware" 
 }  

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

To use alsa instead of pulseaudio, the first audio_output block should look like below:

audio_output {
        type            "alsa"
        name            "Alsa for audio sound card"
        mixer_type      "software"      # optional
}

Add your mpd username to your login group and audio group

sudo gpasswd -a mpd <your login group>
sudo gpasswd -a mpd audio

Test that the configuration file is valid by starting mpd.

$ mpd
$ ss -tunelp | grep 6600
tcp    LISTEN     0 5 127.0.0.1:6600  *:* users:(("mpd",pid=10906,fd=8)) uid:1000 ino:269403 sk:8 <->

mpd.service systemd unit is available for autostart on/usr/lib/systemd/system/mpd.service.

Install and Configure ncmpcpp

Install ncmpcpp on Arch Linux:

sudo pacman -Sy ncmpcpp --noconfirm

Latest development version with AUR:

yay --needed --noconfirm -S ncmpcpp-git

Install and Configure ncmpcpp on Ubuntu

Install ncmpcpp with aptpackage manager:

sudo apt update && sudo apt install ncmpcpp
mkdir -p ~/.ncmcpp/lyrics

Create ncmpcpp config file (this is optional) – You can run ncmpcpp without this!

vim ~/.ncmpcpp/config

Add and customize the following contents:

##
# Files
 mpd_music_dir = "~/Music"  
 lyrics_directory  = ~/.ncmpcpp/lyrics
 ncmpcpp_directory  = ~/.ncmpcpp
 mpd_host = "localhost"
 mpd_port = "6600"  
 mpd_connection_timeout = "5"  
 mpd_crossfade_time = "5"  

 # Playlist
 playlist_disable_highlight_delay = "0"  
 playlist_display_mode = "columns"  
 playlist_show_remaining_time = "yes"

 browser_display_mode = "columns"  
 autocenter_mode = "yes"  
 fancy_scrolling = "yes"  
 follow_now_playing_lyrics = "yes"  
 display_screens_numbers_on_start = "yes"  
 ignore_leading_the = "yes"  
 lyrics_database = "1"  
 song_columns_list_format = "(10)[blue]{l} (30)[green]{a} (30)[magenta]{b} (50)[yellow]{t}"  
 colors_enabled = "yes"  
 main_window_color = "white"  
 main_window_highlight_color =  "blue"
 header_window_color = "cyan"  
 volume_color = "red"  
 progressbar_color = "cyan"  
 statusbar_color = "white"  
 active_column_color = "cyan"  
 active_window_border = "blue"

alternative_header_first_line_format = "$0$aqqu$/a {$7%a - $9}{$5%t$9}|{$8%f$9} $0$atqq$/a$9"
alternative_header_second_line_format = "{{$6%b$9}{ [$6%y$9]}}|{%D}"
song_list_format = "{$3%n │ $9}{$7%a - $9}{$5%t$9}|{$8%f$9}$R{$6 │ %b$9}{$3 │ %l$9}"
user_interface = "alternative"
#user_interface =                    "classic"
default_place_to_search_in = "database"

# visualizer
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "12"
#visualizer_type = "wave" (spectrum/wave)
visualizer_type = "spectrum" (spectrum/wave)
visualizer_in_stereo = "yes"
visualizer_look = "+|"

## Navigation ##
cyclic_scrolling = "yes"
header_text_scrolling = "yes"
jump_to_now_playing_song_at_start = "yes"
lines_scrolled = "2"

## Other ##
system_encoding = "utf-8"
regular_expressions = "extended"

## Selected tracks ##
selected_item_prefix = "* "
discard_colors_if_item_is_selected = "no"

## Seeking ##
incremental_seeking = "yes"
seek_time = "1"

## Visivility ##
header_visibility = "yes"
statusbar_visibility = "yes"
titles_visibility = "yes"

progressbar_look =  "=>-"
progressbar_boldness = "yes"
progressbar_elapsed_color = "white"

now_playing_prefix = "> "
song_status_format = " $2%a $4⟫$3⟫ $8%t $4⟫$3⟫ $5%b "
autocenter_mode = "yes"
centered_cursor = "yes"

# Misc
display_bitrate = "yes"
# enable_window_title = "no"
follow_now_playing_lyrics = "yes"
ignore_leading_the = "yes"
empty_tag_marker = ""

Start ncmpcpp and update mpd database

To start ncmpcpp , just type the command on the terminal:

ncmpcpp 

Once Launched, type u to update the database, it will automatically discover songs on ~/Music/directory:

u

The look should be similar to the one given below:

configure mpd and ncmpcpp on Linux

Mpd playlist as seen on ncmpcpp

If you press 8 or F8, you would see Music visualizer:

configure mpd and ncmpcpp on Linux

Table below serve as a quickstart cheatsheet on navigating ncmpcpp.

Keyboard KeyFunction
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

Here is the complete cheat sheet:

Up k    : Move Cursor up  
r - repeat mode [r-----]
z - random mode [-z----]
y - single mode [--s---] (Repeats the current track after reaching the end.)
R - consume mode [---c--] (Removes the current track from playlist after reaching the end.)
x - crossfade mode [----x-]

     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  

+ - Increase volume 2%
- - Decrease volume 2%
# - Display bitrate of file
= - Clock
F1 - Help


r - repeat mode [r-----]
z - random mode [-z----]
y - single mode [--s---] (Repeats the current track after reaching the end.)
R - consume mode [---c--] (Removes the current track from playlist after reaching the end.)
x - crossfade mode [----x-]
u - Database update

This marks the end of how to install and configure mpd and ncmpcpp on Linux. Consult relevant documentations for Linux distributions not covered here.

Similar articles:

How to install VLC on CentOS / Fedora

Related Articles

Automation How To Install WildFly (JBoss) on Debian 11 / Debian 10 Debian Configure Official repositories to sources.list on Debian 12/11/10 Containers How To Install Podman on Ubuntu 24.04|22.04|20.04 Databases How To Install MariaDB 10.5 on Ubuntu 22.04|20.04

Leave a Comment

Press ESC to close