Sunday, August 25, 2013

MPD and NCMPC setup

I decided on mpd (Music Player Daemon) and ncmpc (NCurses Music Player Client) to play my music.  The following commands install the necessary packages then use insserv to remove mpd from being started automatically by root since I want to configure and run mpd as user.  The cat command output shows that mpd was part of the system startup before the innserv command. After the insserv command the lack of output from that same cat command demonstrates mpd was removed from the startup file. The ps command checks for any instances of mpd, and the final command stops it if needed.
ROOTPROMPT$ apt-get install mpd ncmpc
ROOTPROMPT$ cat /etc/init.d/.depend.start | grep mpd
TARGETS = motd killprocs rpcbind nfs-common rsyslog sudo mpd atd exim4 rsync cron ssh dbus acpid bootlogs single rmnologin rc.local
rmnologin: sudo atd rsyslog rpcbind nfs-common exim4 motd bootlogs rsync cron ssh dbus acpid mpd
rc.local: atd rsyslog rpcbind nfs-common exim4 motd bootlogs rsync cron sudo ssh dbus acpid mpd
ROOTPROMPT$ insserv -r mpd
ROOTPROMPT$ cat /etc/init.d/.depend.start | grep mpd
ROOTPROMPT$ ps aux | grep mpd
root      5029  0.0  0.0 322696  7456 ?        Ssl  23:39   0:00 mpd
root      5033  0.0  0.0   7828   872 pts/1    S+   23:39   0:00 grep mpd
ROOTPROMPT$ /etc/init.d/mpd stop
If your system does not use dependency based boot sequence you will have to configure the mpd service using the update-rc.d command.

update: With systemd I had to run the following to prevent mpd startup on boot
ROOTPROMPT$ systemctl disable mpd
ROOTPROMPT$ systemctl disable mpd.service
ROOTPROMPT$ systemctl disable mpd.socket 
Found help on crunchbang mpd how to

Copy the example mpdconf file to your home directory.
$> gunzip usr/share/doc/mpd/examples/mpd.conf.gz > ~/.mpdconf
Edit this file to change the music_directory, playlist_directory, db_file, log_file, error_file, pid_file, and state_file. Also uncomment the mixer_type line for software volume control.  Below are the relevant exerpts from my config file showing the previous entry (commented out), the comment with my name to remind me I changed it, and my new entry. For easy viewing I've cut the comments, but I recommend reading them as you edit.
#music_directory  "/var/lib/mpd/music"
#ibyrd
music_directory     "/home/byrdi01/music"
...
#playlist_directory  "/var/lib/mpd/playlists"
#ibyrd
playlist_directory  "/home/byrdi01/.mpd/playlists"
...
#db_file   "/var/lib/mpd/tag_cache"
#ibyrd
db_file             "/home/byrdi01/.mpd/database"
...
#log_file   "/var/log/mpd/mpd.log"
#ibyrd
log_file            "/home/byrdi01/.mpd/log"
...
#pid_file   "/var/run/mpd/pid"
#ibyrd
pid_file            "/home/byrdi01/.mpd/pid"
...
#state_file   "/var/lib/mpd/state"
#ibyrd
state_file   "/home/byrdi01/.mpd/state"
...
#ibyrd.  uncomment the next line to enable software control of volume.
mixer_type   "software"

My music is in the "/home/byrdi01/music" directory. Change this as appropriate to tell mpd where your music is located. Create the .mpd/ and .mpd/playlists directories.
$> mkdir -p /home/byrdi01/.mpd/playlists
Now whenever you want to play music you need to start mpd and ncmpc
$> mp
$> ncmpc
The ncmpc client will take up the entire xterm. Press 1 in ncmpc to get the list of commands. 'q' quits ncmpc, but mpd continues, so either stop playing music before exiting ncmpc or run
$> mpd --kill
to kill the daemon.
The mpd wiki has a good mpd configuration page, and I used some information from the mpd config on Arch and the mpd config on Ubuntu pages.

No comments:

Post a Comment