mpd and 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.
mpd as a local service
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.
config
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/mpd.pid"
state_file "~/.config/mpd/mpdstate"
sticker_file "~/.config/mpd/sticker.sql"
audio_output {
type "sndio"
name "sndio output"
mixer_type "software"
}
usage
I run mpd manually after logging in through xdm/xenodm. I have the following
in ~/.xsession (~/.xinitrc, if you start X by hand).
... mpd 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(pp)
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.
config
in ~/.config/ncmpc/config
enable-colors no welcome-screen-list no scroll no set-xterm-title yes second-column no enable-mouse yes xterm-title-format ncmpc
mpc
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
tips
cwm keybindings
Edit ~/.cwmrc:
bind-key XF86AudioPlay mpc toggle bind-key XF86AudioNext mpc next bind-key XF86AudioPrev mpc prev
twm keybidings
Windows key + direction keys. Edit ~/.twmrc:
"Down" = m4 : all : f.exec "mpc toggle" "Left" = m4 : all : f.exec "mpc prev" "Right" = m4 : all : f.exec "mpc next"
find and play a song from your library through dmenu
#!/bin/ksh query=$(mpc listall | dmenu -l 24 -i) if [[ $(mpc) != *paused* || $(mpc) != *playing* ]]; then mpc play; fi if [[ $query != "" ]]; then mpc insert "$query"; mpc next fi
rip audio from a youtube video, convert it to mp3
$ yt-dlp --audio-format mp3 -x 'youtube-url'
Cool.