-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathplay-radio
executable file
·62 lines (57 loc) · 1.53 KB
/
play-radio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
unset http_proxy
basename=${0##*/}
if [ "$basename" = "play-radio" ]; then
if [ -n "$1" ]; then
name=$1
else
state_file=~/.cache/play-radio.last
last="$(<$state_file)"
names='radioparadise fluxfm radioeins groovesalad dronezone OFF'
name="$(echo "$names" | rofi -dmenu -sep ' ' -p "Play which station?" -select "$last")"
if [ -z "$name" ]; then
exit
fi
if [ "$name" != "OFF" ];then
echo "$name" > $state_file
fi
fi
fi
PIDFILE=/tmp/.play-radio.pid
if [ -e "$PIDFILE" ]; then
pid="$(cat "$PIDFILE")"
if kill -0 "$pid" 2>/dev/null; then
echo "Killing already running instance.."
kill "$pid"
fi
fi
if [ "$name" = OFF ]; then
exit
fi
echo $$ > "$PIDFILE"
player="mpg123 --timeout 30 --control"
player_pl="mpg123 --timeout 30 --control -@"
aac_player="mplayer -quiet"
# shellcheck disable=SC2086
case $name in
radioparadise)
exec $player_pl http://www.radioparadise.com/m3u/mp3-192.m3u ;;
fluxfm )
exec $player http://www.fluxfm.de/stream-berlin ;;
fluxfm-klubradio )
exec $player http://streams.fluxfm.de/klubradio/mp3-320/audio/ ;;
radioeins )
exec $player_pl http://www.radioeins.de/live.m3u ;;
groovesalad)
exec $player_pl http://somafm.com/groovesalad.pls ;;
groovesalad_aac)
exec $aac_player http://ice2.somafm.com/groovesalad-128-aac ;;
dronezone)
exec $aac_player http://ice3.somafm.com/dronezone-128-aac ;;
*)
if [ "$name#.pls" = "$name" ]; then
exec $player "$name"
else
exec $player_pl "$name"
fi
esac