Skip to content

Commit df04f7d

Browse files
authored
Added new Functions
New Features: - Write played songs to terminal - Write played songs to Logfile - Show Pop-Up Window when new Song is played
1 parent 5efbfc3 commit df04f7d

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

radio

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/bash
22
# Bashtuner V2.0 by Born2Root
33
# Play Internet Radio from Linux Command Line
4+
# Features:
5+
# - Log to played songs to terminal
6+
# - Show Pop-Up Window when new Song is played
47

58
#====> Define Paths
69

710
# Path to radio station list
8-
pfadsender="$HOME/Programme/bashtuner/sender.csv" ;
11+
pfadsender="$HOME/Programme/bashtuner/sender.csv" ;
912

1013
# Path to Logfile and temporary picture save location (album covers)
1114
config_dir=~/.bash_radio
@@ -32,12 +35,27 @@ auswahl=$(awk -F " " '{print $1"\n"$2}' $pfadsender | zenity --list --hide-colum
3235
if [ $? = "1" ] ; then exit 1 ; else
3336
export play=$(cat $HOME/Programme/bashtuner/sender.csv | head -n"$auswahl" | tail -n1 | cut -d' ' -f3)
3437

35-
mplayer $play 2> /dev/null | awk -F\' '/StreamTitle/ {print $2}'
38+
## old solution - current played song ist only printed to terminal
39+
#mplayer $play 2> /dev/null | awk -F\' '/StreamTitle/ {print $2}'
40+
#echo 'message:' | zenity --notification --listen
3641

37-
#print current played song to terminal
38-
echo 'message:' | zenity --notification --listen
3942

43+
## new solution - current song is showed with Pop-Up window, printed to terminal and logged in logfile
44+
mplayer $play 2>/dev/null | stdbuf -o L grep --text ICY > $fifo &
4045

46+
while read line < $fifo; do
47+
args=$(echo $line | sed -r "s/ICY Info: StreamTitle='([^-]*) - ([^']*)';StreamUrl='([^']*)';/\1;\2;\3/")
48+
saveIFS=$IFS; IFS=";"; set -- $args; IFS=$saveIFS
49+
50+
# Show PopUp Window 10s long, containing Song info and Cover if present
51+
#wget -q $3 -O $image_file 2>/dev/null
52+
notify-send -t 10000 -i $image_file "$1" "$2" 2>/dev/null
53+
54+
# write played songs to Logfile
55+
#echo $(date +%D) $1 - $2 >> $log_file
56+
# write played songs to terminal
57+
echo $1 - $2
58+
done
4159
#wait
4260
playradio
4361
fi

0 commit comments

Comments
 (0)