diff --git a/radio.sh b/radio.sh index 15ccb7c..644d769 100755 --- a/radio.sh +++ b/radio.sh @@ -1,15 +1,26 @@ #!/bin/bash # To add your own stations, put them in ~/.config/radio.sh.conf +declare -A stations=( + [NS Hit Radio ]="https://listen.nshitradio.com/" + [The Metal Plague ]="http://46.4.40.246:8386/" + [The True Monster ]="http://procyon.shoutca.st:8428/stream?fbclid=IwAR37SD7AucBHp-woBj7QyoeQPzQkCTW2BBI-CR1Q9W1hIMvIJhV9iQRQYMs" + [Thunder Rock ]="http://ice10.securenetsystems.net/KTHU2" + $( [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" ]] && source "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf") +) if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" ]]; then - source "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" -else - declare -A stations=( - [NS Hit Radio ]="https://listen.nshitradio.com/" - [The Metal Plague ]="http://46.4.40.246:8386/" - [The True Monster ]="http://procyon.shoutca.st:8428/stream?fbclid=IwAR37SD7AucBHp-woBj7QyoeQPzQkCTW2BBI-CR1Q9W1hIMvIJhV9iQRQYMs" - [Thunder Rock ]="http://ice10.securenetsystems.net/KTHU2" - ) + while IFS="=" read -r key value; do + if [[ "$key" =~ ^\[.*\]$ && "$value" =~ ^\".*\"$ ]]; then + key="${key#[}" + key="${key%]}" + value="${value#\"}" + value="${value%\"}" + stations["$key"]="$value" + else + echo "Error: invalid format in ${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" >&2 + exit 1 + fi + done < <(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf") fi