You are not logged in.
This short guide describes how to install mpd as a user service in Devuan 2.1 (ascii).
Install mpd and mpc
#apt install mpd mpc
Mpc is a command line user interface for MPD server.
By default Devuan installs mpd as a system service. We don't want this, so let's remove it from startup.
If mpd is running stop it first.
#/etc/init.d/mpd stop
We don't want MPD to be started as a system service. We want to run it from a regular user account. So we must disable it. Use this command:
#update-rc.d mpd disable
To build the user configuration, extract and copy the default config with command
gunzip -c /usr/share/doc/mpd/examples/mpd.conf.gz
to directory
~/.config/mpd
(make this dir first).
Edit the config file according to your needs. For example, my config looks like this:
music_directory "~/Music"
playlist_directory "~/Playlists"
db_file "~/.local/share/mpd/mpd.db"
log_file "~/.local/share/mpd/mpd.log"
pid_file "~/.local/share/mpd/mpd.pid"
state_file "~/.local/share/mpd/mpd.state"
sticker_file "~/.local/share/mpd/sticker.sql"
bind_to_address "127.0.0.1"
log_level "default"
restore_paused "yes"
metadata_to_use "artist,album,title,track,date"
auto_update "yes"
input {
plugin "curl"
}
audio_output {
type "alsa"
name "Headset"
mixer_type "software"
}
audio_output {
type "fifo"
name "mpd_fifo"
path "/tmp/mpd.fifo"
format "44100:16:2"
}
Don't forget to create the needed directories (~/Playlists and ~/.local/share/mpd)
Run mpd.
$ mpd
If everything is ok, it directly detaches itself. (so it looks like it exits). It might complain that the db_file cannot be found, you can safely ignore this.
In order to build the database file, MPD must scan into the music_directory. A MPD client is required to request this task, for example with mpc the command is
$ mpc update
.
You most likely want to have mpd started automatically when logging into tty. To start MPD on login add the following to
~/.profile
# MPD daemon start (if no other user instance exists)
[ ! -s ~/.config/mpd/pid ] && mpd
That's it. Now you can enjoy your favorite music.
P.S.
In this simple set up i use command line user interface for MPD server. Here you can see the commands used in mpc. But there are more clients in the official Devuan repository (TUI and GUI).
Last edited by Ogis1975 (2020-01-12 18:55:55)
What economists call over-production is but a production that is above the purchasing power of the worker, who is reduced to poverty by capital and state.
----+- Peter Kropotkin -+----
Offline
Thanks for sharing the guide Ogis1975, When it comes to cli audio player mpd (Daemon) is irreplaceable.
Last edited by Nili (2020-01-15 14:50:17)
Tumbleweed - KDE Plasma (Wayland) - Breeze (LeafDark) [Qt]
♪Mahara★Japaaan!
Offline
Great! mpd is so fun to play with, and you can strip it down to 1mb if you do not need anything fancy.
Here is a system wide init script:
--CUT--
#!/bin/sh
### BEGIN INIT INFO
# Provides: mpd
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: autofs $network $named alsa-utils pulseaudio avahi-daemon
# Should-Stop: autofs $network $named alsa-utils pulseaudio avahi-daemon
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Music Player Daemon
# Description: Start the Music Player Daemon (MPD) service
# for network access to the local audio queue.
### END INIT INFO
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=mpd
DESC="Music Player Daemon"
DAEMON=/usr/local/bin/mpd
MPDCONF=/usr/local/etc/mpd.conf
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
if [ -n "$MPD_DEBUG" ]; then
set -x
MPD_OPTS=--verbose
fi
PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p' $MPDCONF)
mpd_start () {
log_daemon_msg "Starting $DESC" "$NAME"
if [ -z "$PIDFILE" ]; then
log_failure_msg \
"$MPDCONF must have pid_file set; cannot start daemon."
exit 1
fi
PIDDIR=$(dirname "$PIDFILE")
if [ ! -d "$PIDDIR" ]; then
mkdir -m 0755 $PIDDIR
if dpkg-statoverride --list --quiet /run/mpd > /dev/null; then
# if dpkg-statoverride is used update it with permissions there
dpkg-statoverride --force --quiet --update --add $( dpkg-statoverride --list --quiet /run/mpd ) 2> /dev/null
else
# use defaults
chown mpd:audio $PIDDIR
fi
fi
start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" \
--exec "$DAEMON" -- $MPD_OPTS "$MPDCONF" &
log_end_msg $?
}
mpd_stop () {
if [ -z "$PIDFILE" ]; then
log_failure_msg \
"$MPDCONF must have pid_file set; cannot stop daemon."
exit 1
fi
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --oknodo --retry 5 --pidfile "$PIDFILE" \
--exec $DAEMON
log_end_msg $?
}
# note to self: don't call the non-standard args for this in
# {post,pre}{inst,rm} scripts since users are not forced to upgrade
# /etc/init.d/mpd when mpd is updated
case "$1" in
start)
mpd_start
;;
stop)
mpd_stop
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME
;;
restart|force-reload)
mpd_stop
mpd_start
;;
force-start)
mpd_start
;;
force-restart)
mpd_stop
mpd_start
;;
force-reload)
mpd_stop
mpd_start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 2
;;
esac
--CUT--
Offline
And my /etc/asound.conf - this gives you OSS emulation and "native" ALSA with separate volume controls. Note: you have to use them before they show up in alsamixer.
-- CUT --
pcm.softvol {
type softvol
slave {
pcm "dmix"
}
control {
name "Default Playback Volume"
card 0
}
}
pcm.!default {
type plug
slave.pcm "softvol"
}
pcm.dsp0 {
type plug
slave.pcm "dmix"
control.name "sbagen"
control.card 0
}
# MPD volume
pcm.mpd {
type softvol
slave.pcm "plug:dmix"
control.name "MPD Playback Volume"
control.card 0
}
ctl.mpd {
type hw
card 0
}
-- CUT --
PS: Remember to install alsa-oss before trying this!
Last edited by therion23 (2020-02-07 06:43:51)
Offline
Thank you, therion23, for your configs. In near future i will try this.
What economists call over-production is but a production that is above the purchasing power of the worker, who is reduced to poverty by capital and state.
----+- Peter Kropotkin -+----
Offline
Most welcome - especially the softvol "trick" is necessary for certain Raspberry Pi DAC's without hardware volume (the pHAT DAC and some Hifiberry models, for instance).
Offline
This short guide describes how to install mpd as a user service in Devuan 2.1 (ascii).
Install mpd and mpc#apt install mpd mpc
Mpc is a command line user interface for MPD server.
My favorite front end for MPD is YMPD. https://www.ympd.org/
Written in C
Very Lightweight and extremely fast
Built in Web server - no external web server neede
Uses HTM5 and WebSockets
Have MPD and YMPD installed on a couple of PI Zeros. One PI Zero with a 5 dollar USB Sound card is connected to an original Bose Wave Radio and the other is connected to my Biuetooth Speaker.
I have built is on Raspbian so it should build fine on Devuan as well.
Offline
Thank you for the info, Vernon
What economists call over-production is but a production that is above the purchasing power of the worker, who is reduced to poverty by capital and state.
----+- Peter Kropotkin -+----
Offline