VLC Radiostation Bash script
October 17th, 2011
No comments
We use the following script to have our linux machine automatically start playing audio at startup. Every day another radio station will be played with a random choice for some days. It could use some functions to make it a bit tidier, but I’m satisfied with it at this point. 🙂
#!/bin/bash # Arrow Classic Rock radio_stations[0]=http://www.garnierstreamingmedia.com/asx/streamerswitch.asp?stream=205 # City FM radio_stations[1]=http://streams.cityfm.nl:8043/listen.pls # QMusic radio_stations[2]=http://vip2.str.reasonnet.com/qmusic.mp3.96 # Eagle FM radio_stations[3]=http://www.181.fm/asx.php?station=181-eagle #current day of week, 0 is sunday curr_day_of_week=$(date +%w) case $curr_day_of_week in 0) number=$RANDOM let "number %= ${#radio_stations[@]}" /usr/bin/vlc ${radio_stations[$number]} ;; 1) /usr/bin/vlc ${radio_stations[0]} ;; 2) /usr/bin/vlc ${radio_stations[1]} ;; 3) /usr/bin/vlc ${radio_stations[2]} ;; 4) /usr/bin/vlc ${radio_stations[3]} ;; 5) number=$RANDOM let "number %= ${#radio_stations[@]}" /usr/bin/vlc ${radio_stations[$number]} ;; 6) number=$RANDOM let "number %= ${#radio_stations[@]}" /usr/bin/vlc ${radio_stations[$number]} ;; esac |