How to Configure MPD and ncmpcpp on Linux
How to Configure MPD and ncmpcpp on Linux
Music Player Daemon (MPD) is a powerful, flexible, and lightweight music server that allows you to play music and control playback from multiple clients. ncmpcpp is one of the most popular and feature-rich MPD clients that runs in the terminal. Together, they create an efficient and customizable music setup for Linux users who prefer a command-line interface.
This guide will walk you through the process of installing, configuring, and using MPD and ncmpcpp on Linux.
Step 1: Install MPD and ncmpcpp
Both MPD and ncmpcpp are available in the package repositories of most Linux distributions.
For Ubuntu/Debian:
sudo apt update
sudo apt install mpd ncmpcpp
For Fedora:
sudo dnf install mpd ncmpcpp
For Arch Linux:
sudo pacman -S mpd ncmpcpp
Step 2: Configure MPD
After installation, you’ll need to configure MPD to work properly. The configuration file for MPD is typically located in /etc/mpd.conf for system-wide use or ~/.config/mpd/mpd.conf for user-specific configuration.
Here’s a basic mpd.conf setup:
Create MPD Directory Structure:
mkdir -p ~/.config/mpd
mkdir -p ~/Music ~/.config/mpd/playlists ~/.config/mpd/database ~/.config/mpd/log
touch ~/.config/mpd/mpd.conf ~/.config/mpd/log/mpd.log ~/.config/mpd/database/mpd.db
Edit MPD Configuration:
You can edit the mpd.conf file with your preferred text editor:
nano ~/.config/mpd/mpd.conf
Below is an example of a minimal configuration:
music_directory “~/Music”
playlist_directory “~/.config/mpd/playlists”
db_file “~/.config/mpd/database/mpd.db”
log_file “~/.config/mpd/log/mpd.log”
pid_file “~/.config/mpd/mpd.pid”
state_file “~/.config/mpd/state”
sticker_file “~/.config/mpd/sticker.sql”
bind_to_address “localhost”
auto_update “yes”audio_output {
type “pulse”
name “PulseAudio Output”
}
In this setup:
music_directory points to your music folder.
playlist_directory holds your saved playlists.
bind_to_address restricts MPD to the local machine (localhost).
audio_output specifies the output sound system. In this case, PulseAudio is used, but you can modify it to suit your audio setup (ALSA, JACK, etc.).
Start MPD:
After configuring the file, start the MPD service:
mpd
If MPD is already running and you’ve made changes to the configuration, restart the service:
mpc update
mpc rescan
Step 3: Configure ncmpcpp
Now that MPD is configured, you’ll set up ncmpcpp. The configuration file for ncmpcpp is usually located in ~/.config/ncmpcpp/config.
Create the ncmpcpp configuration file:
mkdir -p ~/.config/ncmpcpp
nano ~/.config/ncmpcpp/config
Basic ncmpcpp Configuration:
Here’s a sample ncmpcpp configuration file:
mpd_host = “localhost”
mpd_port = “6600”
mpd_music_dir = “~/Music”
visualizer_output_name = “my_visualizer”
song_columns_list_format = “(25%)|{l}|{a}|{t}|{l}”
browser_sort_by = “name”
playlist_show_remaining_time = “yes”
In this configuration:
mpd_host is set to localhost, meaning ncmpcpp will connect to the local MPD instance.
mpd_music_dir specifies your music directory.
song_columns_list_format defines how the song list is displayed, showing length, artist, and title.
playlist_show_remaining_time enables the display of remaining time for songs in the playlist.
Visualizer Configuration (Optional):
ncmpcpp includes a real-time visualizer that shows music frequency bars. You can enable the visualizer by adding these lines:
visualizer_in_stereo = “yes”
visualizer_type = “wave”
visualizer_look = “██”
Step 4: Using MPD and ncmpcpp
Once both MPD and ncmpcpp are set up, you can launch ncmpcpp by typing:
ncmpcpp
Here are some key commands to navigate and use ncmpcpp:
Arrow keys: Navigate through the interface.
Enter: Play a song or open a playlist.
1 through 8: Switch between different views (library, playlist, visualizer, etc.).
u: Update the music library.
a: Add a song to the playlist.
d: Delete a song from the playlist.
q: Quit ncmpcpp.
Step 5: Autostart MPD at Boot (Optional)
If you want MPD to start automatically at boot, you can enable the systemd service:
sudo systemctl enable mpd
sudo systemctl start mpd
This ensures that MPD will be running whenever you log into your system, allowing you to immediately use ncmpcpp to control your music.
Conclusion
Configuring MPD and ncmpcpp on Linux provides a lightweight, flexible music server and client system that can be fully controlled from the command line. This setup is ideal for users who prefer a minimalist environment but still want powerful music management features.
By following this guide, you now have a complete MPD and ncmpcpp setup to organize and play your music with ease. For more advanced configurations and features, check out the official documentation for MPD and ncmpcpp.
This guide outlines how to install, configure, and use MPD and ncmpcpp, providing a smooth experience for Linux users looking to manage their music through the command line.