summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xradio69
1 files changed, 43 insertions, 26 deletions
diff --git a/radio b/radio index 2078dfe..ba317b4 100755 --- a/radio +++ b/radio
@@ -43,6 +43,49 @@ EOF
43 exit ${1:-0} 43 exit ${1:-0}
44} 44}
45 45
46main() {
47 while getopts :kKsShel: opt; do
48 case $opt in
49 h) usage ;;
50 k) _radio_kill ;;
51 K)
52 pkill "$RADIO_PLAYER"
53 exit
54 ;;
55 e) _radio_edit ;;
56 s) _radio_status ;;
57 S) _radio_status -f ;;
58 l) _radio_list "$OPTARG" ;;
59 :)
60 case "$OPTARG" in
61 l) _radio_list ;;
62 *)
63 echo >&2 "Option -$OPTARG requires an argument"
64 exit 1
65 ;;
66 esac
67 ;;
68 \?)
69 echo >&2 "Uknown option: -$OPTARG"
70 exit 1
71 ;;
72 esac
73 done
74 shift $((OPTIND - 1))
75 _radio_play "$@"
76}
77
78_radio_status() {
79 if [ "x$1" = x-f ]; then
80 follow=-f
81 else
82 follow=
83 fi
84 tail -n4 $follow "$RADIO_STATUS_FILE"
85 echo
86 exit
87}
88
46_radio_play() { 89_radio_play() {
47 candidates="$(sed -e 1d -e '/^#/d' "$RADIO_STATIONS" | grep -i "$1")" 90 candidates="$(sed -e 1d -e '/^#/d' "$RADIO_STATIONS" | grep -i "$1")"
48 if [ -z "$candidates" ]; then 91 if [ -z "$candidates" ]; then
@@ -98,30 +141,4 @@ _radio_list() {
98 exit 141 exit
99} 142}
100 143
101main() {
102 while getopts :khel: opt; do
103 case $opt in
104 h) usage ;;
105 k) _radio_kill ;;
106 e) _radio_edit ;;
107 l) _radio_list "$OPTARG" ;;
108 :)
109 case "$OPTARG" in
110 l) _radio_list ;;
111 *)
112 echo >&2 "Option -$OPTARG requires an argument"
113 exit 1
114 ;;
115 esac
116 ;;
117 \?)
118 echo >&2 "Uknown option: -$OPTARG"
119 exit 1
120 ;;
121 esac
122 done
123 shift $((OPTIND - 1))
124 _radio_play "$@"
125}
126
127main "$@" 144main "$@"