I'm trying to switch from using the local network to a UNIX socket with mpd.To do so, i have my config file:
# Recommended location for database
db_file "~/.config/mpd/database"
# If running mpd using systemd, delete this line to log directly to systemd.
#log_file "syslog"
# The music directory is by default the XDG directory, uncomment to amend and choose a different directory
music_directory "~/Music"
# Uncomment to refresh the database whenever files in the music_directory are changed
auto_update "yes"
auto_update_depth "5"
# Uncomment to enable the functionalities
playlist_directory "~/.config/mpd/playlists"
pid_file "~/.config/mpd/pid"
state_file "~/.config/mpd/state"
#sticker_file "~/.config/mpd/sticker.sql"
bind_to_address "~/.config/mpd/socket"
restore_paused "yes"
audio_output {
type "pipewire"
name "PipeWire Sound Server"
}
I created a socket file in the folder ~/.config/mpd/socket
I also export MPD_HOST=~/.config/mpd/socket in order to be the default host. Nevertheless if i run the command:
mpc play , i have the error MPD error: Failed to resolve host name
But if i run MPD_HOST=~/.config/mpd/socket mpc play it work. I don't understand what i'm missing?
In case others come across this question and have the same problem, I found the solution.
For whatever reason, the
MPD_HOSTenvironment variable needs to be an absolute path./home/user/.var/mpd/socketworks, but~/.var/mpd/socketdoes not.When you run
MPD_HOST=~/.config/mpd/socket mpc playon the command line, the shell is automatically expandingMPD_HOSTto the full path, and so works fine. It is only when the environment variable is being loaded elsewhere, like from a config file, that this expansion doesn't always take place (depends on your shell and distro) and results in an error from mpc.You can look at the active environment variables in your shell (such as by using
setwith no parameters), to see ifMPD_HOSTis available, and whether it has been expanded or not.