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