From ba704be5c48fbda58e704ed9fd84e68576811f43 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:14:58 +0200 Subject: [PATCH] Add ALSA_CARD from addon options --- birdnet-go/rootfs/etc/cont-init.d/99-run.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/birdnet-go/rootfs/etc/cont-init.d/99-run.sh b/birdnet-go/rootfs/etc/cont-init.d/99-run.sh index 10780b58e..57aad64c4 100755 --- a/birdnet-go/rootfs/etc/cont-init.d/99-run.sh +++ b/birdnet-go/rootfs/etc/cont-init.d/99-run.sh @@ -6,9 +6,18 @@ set -e # INITALISATION # ################# -bashio::log.info "ALSA_CARD option is set to $(bashio::config "ALSA_CARD"). If the microphone doesn't work, please adapt it" echo " " +# Check if alsa_card is provided +CONFIG_LOCATION="/config/config.yaml" +if bashio::config.has_value "ALSA_CARD"; then + alsa_card=$(bashio::config 'ALSA_CARD') + bashio::log.info "ALSA_CARD option set to $alsa_card" + bashio::log.info "ALSA_CARD option is set to ${alsa_card}. Please ensure it is the correct card" + sed -i "s/card:.*/card: ${alsa_card}/g" "$CONFIG_LOCATION" + yq -i -y ".audio.card = \"${alsa_card}\"" "${CONFIG_FILE}" +fi + # Adjust microphone volume if needed if command -v amixer > /dev/null 2> /dev/null; then current_volume="$(amixer sget Capture | grep -oP '\[\d+%\]' | tr -d '[]%' | head -1 2> /dev/null || echo "100")" || true