diff --git a/mpd/Dockerfile b/mpd/Dockerfile new file mode 100644 index 0000000..9911fa2 --- /dev/null +++ b/mpd/Dockerfile @@ -0,0 +1,11 @@ +ARG BUILD_FROM +FROM $BUILD_FROM + +RUN apk add --no-cache \ + mpc=0.35-r0 \ + mpd=0.23.15-r2 \ + ympd=1.3.0-r12 + +ENTRYPOINT [ "/init" ] +CMD [] +COPY root / diff --git a/mpd/build.yaml b/mpd/build.yaml new file mode 100644 index 0000000..d7e2bbf --- /dev/null +++ b/mpd/build.yaml @@ -0,0 +1,6 @@ +build_from: + armhf: ghcr.io/home-assistant/armhf-base:3.21 + armv7: ghcr.io/home-assistant/armv7-base:3.21 + aarch64: ghcr.io/home-assistant/aarch64-base:3.21 + amd64: ghcr.io/home-assistant/amd64-base:3.21 + i386: ghcr.io/home-assistant/i386-base:3.21 diff --git a/mpd/config.yaml b/mpd/config.yaml new file mode 100644 index 0000000..d73ed78 --- /dev/null +++ b/mpd/config.yaml @@ -0,0 +1,25 @@ +name: MPD +version: dev +slug: mpd +panel_icon: mdi:music-circle +description: Music Player Daemon is a free and open source music player. It plays audio files, organizes playlists and maintains a music database +url: https://forgejo.owo.monster/chaos/hass-mpd +arch: + - armv7 + - armhf + - aarch64 + - amd64 + - i386 +init: false +audio: true +devices: + - /dev/snd +map: + - share:rw + - media:rw +ports: + 6600/tcp: 6600 +ports_description: + 6600/tcp: MPD +options: +schema: diff --git a/mpd/icon.png b/mpd/icon.png new file mode 100644 index 0000000..0063045 Binary files /dev/null and b/mpd/icon.png differ diff --git a/mpd/logo.png b/mpd/logo.png new file mode 100644 index 0000000..fd42286 Binary files /dev/null and b/mpd/logo.png differ diff --git a/mpd/root/etc/mpd.conf b/mpd/root/etc/mpd.conf new file mode 100644 index 0000000..ae61000 --- /dev/null +++ b/mpd/root/etc/mpd.conf @@ -0,0 +1,29 @@ + +music_directory "/media/mpd/music" +playlist_directory "/media/mpd/playlists" +db_file "/data/database/mpd.db" +sticker_file "/data/sticker.sql" +filesystem_charset "UTF-8" + +log_file "syslog" +log_level "default" +bind_to_address "0.0.0.0" +port "6600" +zeroconf_enabled "no" +host_permissions "127.0.0.1 read,add,control,admin" + +audio_output { + type "pulse" + name "Home Assistant Pulseaudio" +} +audio_output_format "48000:24:2" +audio_buffer_size "4096" +resampler { + plugin "soxr" + quality "very high" + threads "0" +} + +replaygain "track" +auto_update "yes" +metadata_to_use "title,artist" \ No newline at end of file diff --git a/mpd/root/etc/s6-overlay/s6-rc.d/mpd/producer-for b/mpd/root/etc/s6-overlay/s6-rc.d/mpd/producer-for new file mode 100644 index 0000000..e69de29 diff --git a/mpd/root/etc/s6-overlay/s6-rc.d/mpd/run b/mpd/root/etc/s6-overlay/s6-rc.d/mpd/run new file mode 100644 index 0000000..8322b7f --- /dev/null +++ b/mpd/root/etc/s6-overlay/s6-rc.d/mpd/run @@ -0,0 +1,57 @@ +#!/command/with-contenv bashio +set -e + +# Enable Jemalloc for better memory handling +export LD_PRELOAD="/usr/local/lib/libjemalloc.so.2" + +bashio::log.info 'Setup Folders' + +MEDIA_FOLDER=$(bashio::config 'media_folder') +PLAYLIST_FOLDER=$(bashio::config 'playlist_folder') + +mkdir -p /data/database \ + "/media/mpd/media" \ + "/media/mpd/playlists" + +bashio::log.info 'Setup settings' + +if [ "$(bashio::config 'custom_config')" != 'null' ]; then + bashio::log.info 'Use custom config' + cp "$(bashio::config 'custom_config')" '/etc/mpd.conf' +else + bashio::log.info 'Set media folder' + MEDIA_FOLDER=$(bashio::config 'media_folder') + sed -i "s/music_directory.*/music_directory \"${MEDIA_FOLDER//\//\\/}\"/" /etc/mpd.conf + + bashio::log.info 'Set playlist folder' + PLAYLIST_FOLDER=$(bashio::config 'playlist_folder') + sed -i "s/playlist_directory.*/playlist_directory \"${PLAYLIST_FOLDER//\//\\/}\"/" /etc/mpd.conf + + if [ "$(bashio::config 'volume_normalization')" == 'true' ]; then + sed -i "/^#volume_normalization/s/^#//" /etc/mpd.conf + fi + + if [ "$(bashio::config 'verbose')" == 'true' ]; then + sed -i "/^log_level/s/default/verbose/" /etc/mpd.conf + fi + + if [ "$(bashio::config 'httpd_output')" == 'true' ]; then + printf '\n + audio_output { \n + type "httpd" \n + name "HTTPd Output" \n + port "8000" \n + bitrate "192" \n + always_on "yes" \n + }' >> /etc/mpd.conf + bashio::log.info 'HTTPd output enabled' + fi +fi + +chown root:root /usr/bin/mpd +chown root:root /usr/bin/mpc +chmod 0774 /usr/bin/mpd +chmod 0774 /usr/bin/mpc + +bashio::log.info 'Start MPD' +mpd --stdout --no-daemon diff --git a/mpd/root/etc/s6-overlay/s6-rc.d/mpd/type b/mpd/root/etc/s6-overlay/s6-rc.d/mpd/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/mpd/root/etc/s6-overlay/s6-rc.d/mpd/type @@ -0,0 +1 @@ +longrun diff --git a/mpd/root/etc/s6-overlay/s6-rc.d/user/contents.d/mpd b/mpd/root/etc/s6-overlay/s6-rc.d/user/contents.d/mpd new file mode 100644 index 0000000..e69de29 diff --git a/repository.yaml b/repository.yaml new file mode 100644 index 0000000..2db238d --- /dev/null +++ b/repository.yaml @@ -0,0 +1,3 @@ +name: MPD Plugin Repo +url: 'https://forgejo.owo.monster/chaos/hass-mpd' +maintainer: chaos \ No newline at end of file