Friday, October 11, 2024
Google search engine
HomeGuest BlogsHow to configure mpd and ncmpcpp on Linux

How to configure mpd and ncmpcpp on Linux

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

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:

  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 How to Install and configure mpd and ncmpcpp on MacOS

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

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 -S mpd --noconfirm

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

yay – Best AUR Helper for Arch Linux / Manjaro

$ 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-get install mpd

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

MPD 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>
$ chmod 710 ~/
$ 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 -S ncmpcpp --noconfirm

Latest development version with AUR:

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

Install and Configure ncmpcpp on Ubuntu

Install ncmpcpp with apt-get

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

Add ncmpcpp config file:

$ vim ~/.ncmpcpp/config

Add content:

##
# 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 Key Function
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

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 7 / Fedora 29 / Fedora 28

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments