Played a little with this, there are just a few stations, but it looks ok to me.
I have compiled the latest yad and mpg123, so I'm not sure how it works with older versions.
![](http://i.imgur.com/Ij1rkRMm.png)
It's a little slow on exit but that's how the remote control works with mpg123. There is a 10 seconds sleep on quit, then if mpg123 doesn't want to quit, we call the "killall".
How to setup? First you need a stations file. I think it's better to keep the stations out of the script. It's easier to maintain them this way.
There are just a few stations in there for now.
Honestly, I lost the willpower after seeing how many stations are there in the original pmrp script![Cheesy :D](https://vsido.org/Smileys/default/cheesy.gif)
stations file:
OK, now the script (remember to change the path to stations file in this line => export pmrp_stations="/home/misko/Desktop/pmrpui/stations")
I have compiled the latest yad and mpg123, so I'm not sure how it works with older versions.
![](http://i.imgur.com/Ij1rkRMm.png)
It's a little slow on exit but that's how the remote control works with mpg123. There is a 10 seconds sleep on quit, then if mpg123 doesn't want to quit, we call the "killall".
How to setup? First you need a stations file. I think it's better to keep the stations out of the script. It's easier to maintain them this way.
There are just a few stations in there for now.
Honestly, I lost the willpower after seeing how many stations are there in the original pmrp script
![Cheesy :D](https://vsido.org/Smileys/default/cheesy.gif)
stations file:
Code Select
## Stations
# Tag: "Name" "Category" "URL"
## 181.FM
181.FM: "Chilled Out" "Techno" "http://relay.181.fm:8700"
181.FM: "Energy 93" "Techno" "http://relay.181.fm:8044"
181.FM: "Energy 98" "Techno" "http://relay.181.fm:8800"
181.FM: "Studio 181" "Techno" "http://relay.181.fm:8072"
181.FM: "Techno Club" "Techno" "http://icyrelay.181.fm/181-technoclub_128k.mp3"
181.FM: "The Vibe of Vegas" "Techno" "http://relay.181.fm:8074"
181.FM: "Jammin 181" "Urban" "http://relay.181.fm:8042"
181.FM: "Old School HipHop" "Urban" "http://relay.181.fm:8068"
181.FM: "The Beat" "Urban" "http://relay.181.fm:8054"
181.FM: "The Box" "Urban" "http://relay.181.fm:8024"
181.FM: "True R&B" "Urban" "http://relay.181.fm:8022"
# Needs at least one empty new line at the end of the list
# to avoid yad list issue
OK, now the script (remember to change the path to stations file in this line => export pmrp_stations="/home/misko/Desktop/pmrpui/stations")
Code Select
#!/bin/bash
command -v mpg123 >/dev/null 2>&1 || (yad --text="PMRP requires 'mpg123' but it's not installed!\nInstall 'mpg123' to enjoy PMRP."; exit 1)
TEXTDOMAIN=ydesk
TEXTDOMAINDIR=/usr/share/locale
export pmrp='@bash -c "run_stations %1"'
export pmrp_stations="/home/misko/Desktop/pmrpui/stations"
export fpipe=$(mktemp -u --tmpdir pmrp.XXXXXXXX)
export ppipe=$(mktemp -u --tmpdir ppmrp.XXXXXXXX)
export cpipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
mkfifo "$fpipe"
mkfifo "$ppipe"
mkfifo "$cpipe"
trap "rm -f $fpipe $ppipe $cpipe" EXIT
pmkey=$(($RANDOM * $$))
# Categories are separated with "!" (without quotes)
# The last item in category is without trailing "!"
Categories="181.FM!
Blues!
Bollywood!
Classical!
Country!
Electronic!
Hits!
Jazz!
Medley!
Metal!
News_&_Views!
Oldies!
Reggae!
Rock!
SomaFM!
Urban"
function run_stations
{
echo "2:@disable@"
echo -e '\f' >> "$fpipe"
ECHO_ONE='echo "Category: $1" >> "$ppipe"'
ECHO_TWO='echo "-----------------------" >> "$ppipe"'
case "$1" in
181.FM)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Blues)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Bollywood)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Classical)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Country)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Electronic)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Hits)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Jazz)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Medley)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Metal)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
"News_&_Views")
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Oldies)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Reggae)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Rock)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
SomaFM)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
Urban)
echo "Category: $1" >> "$ppipe"
echo "-----------------------" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
;;
*)
echo "PMRP: Error! No such Category $1" >> "$ppipe"
;;
esac
echo "2:$pmrp"
}
export -f run_stations
function load_url
{
echo "Station:$1 Url: $3" >> $ppipe
echo "load $3" > $cpipe
}
export -f load_url
exec 3<> $fpipe
exec 4<> $ppipe
exec 5<> $cpipe
killall mpg123 2>/dev/null
PLAYER="mpg123 --remote --fifo $cpipe --utf8 --title --preload 1 --buffer 768 --smooth"
$PLAYER 2>&1 /dev/null | tee >(awk '/@E/ || /@P/{if ($0=="@P 0") print "PMRP: playing stopped";
else if ($0=="@P 1") print "PMRP: playing paused";
else if ($0=="@P 2") print "PMRP: playing";
else if ($0 ~ "^@E.") print "PMRP:",$1="",$0;
else print $0; fflush(stdout)}' >> "$ppipe") \
>(awk -F'=' '/StreamTitle/{gsub(/'\''/,"",$2);
gsub(/\;/,"",$2); print "Title:", $2; fflush(stdout)}' >> "$ppipe") &>/dev/null &
yad --plug="$pmkey" --tabnum=1 --form --field "Category":CB "$(for category in $Categories; do printf "%s" "$category"; done)" \
--image=radio --image-ontop --field="Load Stations!gtk-add:fbtn" "$pmrp" &
yad --plug="$pmkey" --tabnum=2 --list --no-markup --dclick-action='bash -c "load_url %s"' \
--text "Double click to play" --text-align=center --column="Name" --column="Category" --column="Url" \
--search-column=1 --expand-column=1 --print-column="3" <&3 &
yad --text-info --title="PMRP-Log" --window-icon=radio --posx=710 --posy=100 --width=600 --height=500 --button="gtk-close" <&4 &
echo "PMRP: Ready to Play" >> "$ppipe"
yad --paned --key="$pmkey" --button="Show Log":'bash -c "yad --text-info --title=PMRP-Log --window-icon=radio --posx=710 --posy=100 --width=600 --height=500 < $ppipe" &' \
--button="Pause/Continue":'bash -c "echo pause >> $cpipe"' \
--button="Stop":'bash -c "echo stop >> $cpipe"' --text="Select a Category and click to Load Stations" --width=700 --height=500 \
--title=$"PMRP" --window-icon="radio" --posx=10 --posy=100
[[ $? == 252 ]] && echo quit >> $cpipe
echo "PMRP: Preparing for radio silence" >> "$ppipe"
# Takes a lot to quit, patience
sleep 10
# Well, sometimes it fails to quit, SIGTERM
killall mpg123 2>/dev/null
echo "PMRP: Zzzzzzz" >> "$ppipe"
exec 3>&-
exec 4>&-
exec 5>&-