I have been customizing my desktop's looks lately. If you read my previous articles, you might remember that I am hosting a music server on exozyme. I used Navidrome, the best Subsonic-compatible open source music server available, for the server. Navidrome has a very good web UI, and being compatible with Subsonic means that it is also compatible with apps that was developed for Subsonic as well. Ironically, despite Subsonic has been around since 2004, its ecosystem lacks a good desktop client. Most of the desktop clients are incomplete (supersonic) or very memory intensive (Feishin) or laggy (literally every other clients).
So, I looked for alternative methods. I tried using HTTPDirFS to mount the Navidrome server to a directory, and mopidy, but they are all too slow. Then I found out that MPD can be configured to use WebDAV. MPD's browsing speed is very fast because it generates its own database file. No desktop client for Subsonic had ever attempted to implement their apps this way.
Since MPD has some pretty good looking GUI and TUI clients, I decided to go with it.
My setup
MPD supports multiple storage plugins. I use WebDAV because it is just a HTTP web directory.
ssh
into your server and install rclone.
You can use any other WebDAV server implementations.
I personally use rclone
because it is simple to use.
Now, open the terminal and type:
rclone serve webdav --addr :$PORT_NUMBER \
--webdav-user $USER \ # Optional if you wanted to
--webdav-pass $PASSWORD \ # add authentication
$HOME/path/to/music # Your music directory
# example: rclone serve webdav --addr :8284 --webdav-user vnpower --webdav-pass 0bscur3 /home/vnpower/Music
After that, you should be able to access your WebDAV server at localhost:$PORT_NUMBER
.
Now, for the WebDAV server to be accessible by MPD on your local machine, you will have to expose it via reverse proxy (nginx, caddy, ...) or SSH tunnelling.
If you are a member of exozyme and are currently using it, you could do this:
socat UNIX-LISTEN:/srv/http/webdav,fork,mode=660 TCP4:localhost:8284
# The WebDAV server is now available at webdav.exozy.me
Read more about this dark magic.
Next, on your local machine, edit this one line in ~/.config/mpd/mpd.conf
:
music_directory "https://$USERNAME:$PASSWORD@webdav.example.com"
# If you don't enable authentication, it would just be
# music_directory "https://webdav.example.com"
# Considering the example above:
# music_directory "https://vnpower:0bscur3@webdav.exozy.me"
...
And it's done! Well, not quite. I don't know if you are like me but the MPD database just wouldn't build properly on my machine if I am using this setup. Luckily, there is a way to workaround this issue. That is to build the database directly on the server.
In the server's ~/.config/mpd/mpd.conf
:
...
music_directory "/home/vnpower/path/to/music/"
database {
plugin "simple"
# Where MPD builds its database. I put it inside my music folder to just download it straight
# from the WebDAV server
path "/home/vnpower/path/to/music/mpd.db"
}
audio_output {
type "null"
name "This server does not need to play music, but it can. It's up to you."
}
Then, run mpd
on your server. A database file should be created at the path you specified.
Now, retrieve that database file onto your local machine and configure MPD to read that database file.
And there you go. Open up your MPD client and enjoy!
The downside of this setup is that you will have to regenerate and update your local database to see any new changes you made to the music directory (like, adding new music or moving files around). To be honest, it is worth the tradeoff, since you can write a simple shell script for that.