openbsd freebsd mpd


headphones ad

mpd & ncmpc

mpd is a music player daemon. ncmpc is an interactive text interface for mpd. mpc is a utility for controling mpd via external commands. This is a guide for using the three locally. It's like a music streaming service that runs entirely in your computer with your own music files.

The configuration process is the same for both OpenBSD and FreeBSD, with the only difference being the audio_output block in mpd.conf. Make sure the music_directory exists and (preferably) contains some audio files.

On FreeBSD mpd and mpc ports are called musicpd and musicpc (if you're installing through pkg), but the binaries are still called mpd and mpc.


Create the following directory and populate it with files.

$ mkdir -p ~/.config/mpd/playlists
$ touch ~/.config/mpd/{db,log,pid,state,socket,sticker.sql}

Edit/create ~/.config/mpd/mpd.conf


music_directory "~/music"
playlist_directory "~/.config/mpd/playlists"
db_file "~/.config/mpd/mpd.db"
log_file "~/.config/mpd/mpd.log"
pid_file "~/.config/mpd/"
state_file "~/.config/mpd/mpdstate"
sticker_file "~/.config/mpd/sticker.sql"

audio_output {
        type "sndio"
        name "sndio output"
        mixer_type "software"


music_directory "~/music"
playlist_directory "~/.config/mpd/playlists"
db_file "~/.config/mpd/db"
log_file "~/.config/mpd/log"
pid_file "~/.config/mpd/pid"
state_file "~/.config/mpd/state"
sticker_file "~/.config/mpd/sticker.sql"

audio_output {
        type "oss"
        name "Default OSS device"


I run mpd manually after logging in through xdm/xenodm. I have the following in ~/.xsession (~/.xinitrc, if you start X by hand).

mpc pause

mpc pause is there as a sanity check for when I boot up the computer at a funeral, a restaurant or the cabin of a public transport. If you violently shutdown your machine while a song is playing through mpd, it'll continue playing after you start it again.

Whenever you add music to music directory, run $ mpc update this rebuilds the database and the new songs will be searchable and appear in ncmpc.


ncmpc in xterm in fvwm3

It's a TUI front-end to mpd. It's light, it's easy to use. It's there so you don't have to make playlists with mpc. Some will tell you to get ncmpcpp instead, because it's more colorful and can display ascii visualisations. I'd say get over aesthetics and use the lighter software, but you do you.


Some basic commands to give you an idea. All of these can also be toggled in ncmpc.

$ mpc update # run after adding files to music dir
$ mpc next # play next song in playlist
$ mpc single # play one song and stop
$ mpc consume # remove a song from playlist after playing it


cwm keybindings

edit ~/.cwmrc:

bind-key XF86AudioPlay mpc toggle
bind-key XF86AudioNext mpc next
bind-key XF86AudioPrev mpc prev

find and play a song from your library through dmenu

query=$(mpc listall | dmenu -l 24 -i)
if [[ $(mpc) != *paused* || $(mpc) != *playing* ]]; then
mpc play; fi
if [[ $query != "" ]]; then
mpc insert "$query"; mpc next

rip audio from a youtube video, convert it to mp3

$ yt-dlp --audio-format mp3 -x 'youtube-url'