1
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Between the couch cushions perhaps!?Whish it was between the couch cushions... That was a a big documentation to read.![]()
![]()
Joke aside, I did take a quick look @docs/google, but didn't find anything. The "bad" here is that MPV has support for real remote controlers ( the hardware ones ), which is the main hit on Google, making the shell "remote" we need here hard to find... And the docs are longer then the Bible...
#!/bin/bash
command -v mpv >/dev/null 2>&1 || (yad --text="PMRP requires 'mpv' but it's not installed!\nInstall 'mpv' to enjoy PMRP."; exit 1)
TEXTDOMAIN=ydesk
TEXTDOMAINDIR=/usr/share/locale
export LANG=C.UTF-8
export pmrp='@bash -c "run_stations %2"'
export pmrp_stations="stations"
export fpipe=$(mktemp -u --tmpdir pmrp.XXXXXXXX)
export ppipe=$(mktemp -u --tmpdir ppmrp.XXXXXXXX)
export cpipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export statuspipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export PMRPLIST=$(mktemp -u --tmpdir PMRPLIST.XXXXXXXX)
# Pipe for setting values in the form tab
mkfifo "$fpipe"
# control pipe - send commands to mpv
mkfifo "$cpipe"
# status pipe - send text to left text pane
mkfifo "$statuspipe"
# Create the list file
> $PMRPLIST
trap "rm -f $fpipe $ppipe $cpipe $statuspipe $PMRPLIST" 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!
Serbia!
SomaFM!
Urban"
function stations
{
echo "Category: $1" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
}
export -f stations
function run_stations
{
echo "3:@disabled@"
echo -e '\f' >> "$fpipe"
case "$1" in
181.FM)
stations "$1"
;;
Blues)
stations "$1"
;;
Bollywood)
stations "$1"
;;
Classical)
stations "$1"
;;
Country)
stations "$1"
;;
Electronic)
stations "$1"
;;
Hits)
stations "$1"
;;
Jazz)
stations "$1"
;;
Medley)
stations "$1"
;;
Metal)
stations "$1"
;;
"News_&_Views")
stations "$1"
;;
Oldies)
stations "$1"
;;
Reggae)
stations "$1"
;;
Rock)
stations "$1"
;;
Serbia)
stations "$1"
;;
SomaFM)
stations "$1"
;;
Urban)
stations "$1"
;;
*)
echo "PMRP: Error! No such Category $1" >> "$ppipe"
;;
esac
echo "3:$pmrp"
}
export -f run_stations
function load_url
{
echo "Station: $1 Url: $3" >> $ppipe
# Station to the list
echo "$3" > $PMRPLIST
# Unload current Playlist
echo "playlist_remove current" > $cpipe
# Load list
echo "loadlist $PMRPLIST" > $cpipe
}
export -f load_url
function status_block
{
if [[ ! -z "$PMRP" ]]; then
unset PMRP
else
if [[ "$(echo "$1" | grep -c "^Name*")" = 1 ]]; then
STATION="$1"
elif [[ "$(echo "$1" | grep -c "^Title*")" = 1 ]];then
TITLE="$1"
elif [[ "$(echo "$1" | grep -c "^Bitrate")" = 1 ]];then
BITRATE="$1 Kb/s"
elif [[ "$(echo "$1" | grep -c "^PMRP:*")" = 1 ]];then
PMRP="$1"
fi
if [[ -z "$PMRP" ]]; then
echo "$STATION\n$BITRATE\n$TITLE" >> "$statuspipe"
else
echo "\n$PMRP\n" >> "$statuspipe"
fi
echo "$(for category in $Categories; do printf "%s" "$category"; done)" >> "$statuspipe"
echo "$pmrp" >> "$statuspipe"
fi
}
exec 3<> $fpipe
exec 4<> $ppipe
exec 5<> $cpipe
exec 6<> $statuspipe
echo "PMRP: Ready to Play" >> "$ppipe"
killall mpv 2>/dev/null
mpv --playlist=$PMRPLIST --input-file=$cpipe --cache 2048 --no-config --idle=yes 2>&1 \
| awk '/[statusline]/{if ($0 ~ "icy-br:*") {gsub(/^.*icy-br:/,"");print "Bitrate ", $0 ;}
else {if ($0 ~ "icy-name:*") {gsub(/^.*icy-name:/,"");print "Name ", $0;}
else {if ($0 ~ "icy-genre:*") {gsub(/^.*icy-genre:/,"");print "Genre -", $0;}
else {if ($0 ~ "icy-title:*") {gsub(/^.*icy-title:/,"");print "Title ", $0;}}}}}
{fflush(stdout)}' | while read -r line; do status_block "$line"; echo "$line" >>"$ppipe"; done &
function main() {
yad --plug="$pmkey" --tabnum=1 --form --cycle-read --field "":TXT --field "Category":CB \
--image-ontop --field="Load Stations!gtk-add:fbtn" <&6 &
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 &
# Uncoment next line if you want to start with log
# tail -f "$ppipe" | yad --text-info --title="PMRP-Log" --tail --window-icon=radio --width=600 --height=500 --button="gtk-close" &
# loads fields on startup
status_block "PMRP: Poor Man's Radio Player"
# Reprints metadata after returning from tray
echo 'print_text ${metadata}' > $cpipe
yad --paned --key="$pmkey" --button="Close to Tray!gtk-close":1 \
--button="Show Log":'bash -c "tail -f -n +1 $ppipe | yad --text-info --tail --title=PMRP-Log --window-icon=radio --width=600 --height=500 --button=gtk-close" &' \
--button="Pause/Continue":'bash -c "echo cycle pause >> $cpipe"' \
--button="Stop":'bash -c "echo stop >> $cpipe"' --text="Select a Category and click to Load Stations" --width=700 --height=500 \
--title=$"PMRP" --splitter=300 --window-icon="radio" --orient=hor --image=radio --image-on-top --posx=10 --posy=100
RET="$?"
case $RET in
252)
echo "quit" >> $cpipe
echo "PMRP: Preparing for radio silence" >> "$ppipe"
echo "PMRP: Zzzzzzz" >> "$ppipe"
;;
1) yad --notification \
--image="radio" \
--text="PMRP"
# Need to do this after returned from tray
status_block ""
main
;;
*) exit 1
;;
esac
}
main
exec 3>&-
exec 4>&-
exec 5>&-
exec 6>&-
hey Misko why not post your colour chooser yad script here?Will do. Once I find it.
the one you posted on bunsen labs, I am using it and it works great.
Nice one, working as advertised.Great to see it works.
One suggestion though. For this and future yad scripts add the "--class" flag. That will give your scripts a unique identifier so that per app settings can be applied in fluxbox, openbox, and any other window manager that supports it.
The default is for the name to be "yad" and the class to be "Yad", so any per app settings apply to all scripts.
yad --class "Youtube..."
Cheers MiskoCheers hakerdefo
@Misko@Filip
Nice work!![]()
Couple of notes/ideas:
1. I don't know for sure whether "mpv" has a remote control, however if it does it might be much better then "mpg123" ( atleast there woudn't be a "Quit lag" )
2. "Close to tray" would be awesome, though AFAIK it's not (yet) possible with YAD??
Great job Misko^
No one scripts better in YAD than you
One of these days I'll port all the PMRP stations to the format supported by PMRP-UI. Promise
Cheers!!!
#!/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 %2"'
export pmrp_stations="stations"
export fpipe=$(mktemp -u --tmpdir pmrp.XXXXXXXX)
export ppipe=$(mktemp -u --tmpdir ppmrp.XXXXXXXX)
export cpipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export statuspipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export PMRPID=$(mktemp -u --tmpdir PMRPID.XXXXXXXX)
mkfifo "$fpipe"
mkfifo "$cpipe"
mkfifo "$statuspipe"
trap "rm -f $fpipe $ppipe $cpipe $statuspipe $PMRPID" 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!
Serbia!
SomaFM!
Urban"
function stations
{
echo "Category: $1" >> "$ppipe"
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
}
export -f stations
function run_stations
{
echo "3:@disabled@"
echo -e '\f' >> "$fpipe"
case "$1" in
181.FM)
stations "$1"
;;
Blues)
stations "$1"
;;
Bollywood)
stations "$1"
;;
Classical)
stations "$1"
;;
Country)
stations "$1"
;;
Electronic)
stations "$1"
;;
Hits)
stations "$1"
;;
Jazz)
stations "$1"
;;
Medley)
stations "$1"
;;
Metal)
stations "$1"
;;
"News_&_Views")
stations "$1"
;;
Oldies)
stations "$1"
;;
Reggae)
stations "$1"
;;
Rock)
stations "$1"
;;
Serbia)
stations "$1"
;;
SomaFM)
stations "$1"
;;
Urban)
stations "$1"
;;
*)
echo "PMRP: Error! No such Category $1" >> "$ppipe"
;;
esac
echo "3:$pmrp"
}
export -f run_stations
function load_url
{
echo "Station: $1 Url: $3" >> $ppipe
echo "LOAD $3" >> $cpipe
curl -Is "$3" | awk -F':' '/icy-br/{print "Bitrate:" $2}' >>$ppipe
}
export -f load_url
function status_block
{
if [[ ! -z "$ERROR" ]]; then
unset ERROR
else
if [[ "$(echo "$1" | grep -c "^Station:*")" = 1 ]]; then
STATION="$1"
elif [[ "$(echo "$1" | grep -c "^Title:*")" = 1 ]];then
TITLE="$1"
elif [[ "$(echo "$1" | grep -c "^PMRP:*")" = 1 ]];then
if [[ "$(echo "$1" | grep -c "^PMRP: Error opening stream:*")" = 1 ]];then
ERROR="$1"
else
STATUS="$1"
fi
fi
if [[ -z "$ERROR" ]]; then
echo "$STATION\n$STATUS\n$TITLE" >> "$statuspipe"
else
echo "\n$ERROR\n" >> "$statuspipe"
fi
echo "$(for category in $Categories; do printf "%s" "$category"; done)" >> "$statuspipe"
echo "$pmrp" >> "$statuspipe"
fi
}
exec 3<> $fpipe
exec 4<> $ppipe
exec 5<> $cpipe
exec 6<> $statuspipe
killall mpg123 2>/dev/null
# Don't use buffer here because of geo-locked stations
PLAYER="mpg123 --remote --fifo $cpipe --title --preload 1 --no-resync"
$PLAYER 2>&1 /dev/null | awk '/@E/ || /@P/ || /@I/{if ($0=="@P 0") {print "PMRP: stop";}
else {if ($0=="@P 1") {print "PMRP: paused";}
else {if ($0=="@P 2") {print "PMRP: playing";}
else {if ($0 ~ "@E.*") {print "PMRP:",$1="",$0;}
else {if ($0 ~ "StreamTitle=*") {gsub(/^.*StreamTitle=/,"");gsub(/'\''/,"");gsub(/\;/,"");print "Title:", $0;}
else {if ($0 ~ "ICY-NAME:*"){gsub(/^@I ICY-NAME:/,"");print "Station:", $0}}}}}}}
{fflush(stdout)}' | while read -r line; do status_block "$line"; echo "$line" >>"$ppipe"; done & echo $! > "$PMRPID"
yad --plug="$pmkey" --tabnum=1 --form --cycle-read --field "":TXT --field "Category":CB \
--image-ontop --field="Load Stations!gtk-add:fbtn" <&6 &
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 &
# Uncoment next line if you want to start with log
# tail -f "$ppipe" | yad --text-info --title="PMRP-Log" --tail --window-icon=radio --width=600 --height=500 --button="gtk-close" &
echo "PMRP: Ready to Play" >> "$ppipe"
# loads fields on startup
status_block "PMRP: Poor Man's Radio Player"
yad --paned --key="$pmkey" --button="Show Log":'bash -c "tail -f -n +1 $ppipe | yad --text-info --tail --title=PMRP-Log --window-icon=radio --width=600 --height=500 --button=gtk-close" &' \
--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" --splitter=300 --window-icon="radio" --orient=hor --image=radio --image-on-top --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, kill
kill $(<$PMRPID) 2>/dev/null
echo "PMRP: Zzzzzzz" >> "$ppipe"
exec 3>&-
exec 4>&-
exec 5>&-
exec 6>&-
NOTIFICATION
Allows commands to be sent to yad in the form command:args. Possible
commands are icon, tooltip, visible, action, menu and quit.
icon:ICONNAME
Set notification icon to ICONNAME.
tooltip:STRING
Set notification tooltip.
visible:[true|false|blink]
Set notification icon to visible, invisible or blinking states.
action:COMMAND
Specify the command running when click on the icon. Special
string "quit" exit the program.
menu:STRING
Set popup menu for notification icon. STRING must be in form
name1[!action1[!icon1]]|name2[!action2[!icon2]].... Empty name
add separator to menu. Separator character for values (e.g.
`|') sets with --separator argument. Separator character for
menu items (e.g. `!') sets with --item-separator argument.
quit Exit the program. Middle click on icon also send quit command.
Open a terminal window and enteryad --notification --image="gtk-help" --listen
then enter and type intooltip:Hello\nPackrat
mouse over the icon and you will see a tooltip.quit
This example shows how to use it in a script.#!/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 %2"'
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)
export statuspipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export PMRPID=$(mktemp -u --tmpdir PMRPID.XXXXXXXX)
mkfifo "$fpipe"
mkfifo "$cpipe"
mkfifo "$statuspipe"
trap "rm -f $fpipe $ppipe $cpipe $statuspipe $PMRPID" 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 "3:@disabled@"
echo -e '\f' >> "$fpipe"
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 "3:$pmrp"
}
export -f run_stations
function load_url
{
#status_block "Station: $1 Genre: $2 url: $3"
echo "Station: $1 Url: $3" >> $ppipe
echo "load $3" > $cpipe
}
export -f load_url
function status_block
{
if [[ ! -z "$ERROR" ]]; then
unset ERROR
else
if [[ "$(echo "$1" | grep -c "^Station:*")" = 1 ]]; then
STATION="$1"
elif [[ "$(echo "$1" | grep -c "^Title:*")" = 1 ]];then
TITLE="$1"
elif [[ "$(echo "$1" | grep -c "^PMRP:*")" = 1 ]];then
if [[ "$(echo "$1" | grep -c "^PMRP: Error opening stream:*")" = 1 ]];then
ERROR="$1"
else
STATUS="$1"
fi
fi
if [[ -z "$ERROR" ]]; then
echo "$STATION\n$STATUS\n$TITLE" >> "$statuspipe"
echo "$(for category in $Categories; do printf "%s" "$category"; done)" >> "$statuspipe"
echo "$pmrp" >> "$statuspipe"
else
echo "\n$ERROR\n" >> "$statuspipe"
echo "$(for category in $Categories; do printf "%s" "$category"; done)" >> "$statuspipe"
echo "$pmrp" >> "$statuspipe"
fi
fi
}
export -f status_block
exec 3<> $fpipe
exec 4<> $ppipe
exec 5<> $cpipe
exec 6<> $statuspipe
killall mpg123 2>/dev/null
PLAYER="mpg123 --remote --fifo $cpipe --utf8 --title --preload 1 --buffer 768 --smooth"
$PLAYER 2>&1 /dev/null | awk '/@E/ || /@P/ || /@I/{if ($0=="@P 0") {print "PMRP: stop";}
else {if ($0=="@P 1") {print "PMRP: paused";}
else {if ($0=="@P 2") {print "PMRP: playing";}
else {if ($0 ~ "@E.*") {print "PMRP:",$1="",$0;}
else {if ($0 ~ "StreamTitle=*") {gsub(/^.*StreamTitle=/,"");gsub(/'\''/,"");gsub(/\;/,"");print "Title:", $0;}
else {if ($0 ~ "ICY-NAME:*"){gsub(/^@I ICY-NAME:/,"");print "Station:", $0}}}}}}}
{fflush(stdout)}' | tee >(while read -r line; do status_block "$line"; done) >>"$ppipe" & echo $! > "$PMRPID"
yad --plug="$pmkey" --tabnum=1 --form --cycle-read --field "Status":CB --field "Category":CB \
--image=radio --image-ontop --field="Load Stations!gtk-add:fbtn" <&6 &
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 &
# Uncoment next line if you want to start with log
# tail -f "$ppipe" | yad --text-info --title="PMRP-Log" --tail --window-icon=radio --width=600 --height=500 --button="gtk-close" &
echo "PMRP: Ready to Play" >> "$ppipe"
# loads fields on startup
status_block "PMRP: Poor Man's Radio Player"
yad --paned --key="$pmkey" --button="Show Log":'bash -c "tail -f -n +1 $ppipe | yad --text-info --tail --title=PMRP-Log --window-icon=radio --width=600 --height=500 --button=gtk-close" &' \
--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, kill
kill $(<$PMRPID) 2>/dev/null
echo "PMRP: Zzzzzzz" >> "$ppipe"
exec 3>&-
exec 4>&-
exec 5>&-
exec 6>&-
What do you think? ## 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")#!/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>&-
Hi there misko_2083,Hi hakerdefo.
I envy your YAD skills
yt-get is the best GUI tool out there to download from YouTube. Using jq and json data in yt-get is ingenious
Coming to PMRP, if anyone can dress it in GUI, it's you my friend
Can't wait to see PMRP-YAD
Cheers!!!
#!/bin/bash
i=o
cvlc -I rc -vvv http://relay.181.fm:8042 2>&1 >/dev/null | grep --line-buffered "New Icy-Title=" \
| stdbuf -oL -eL sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g" \
| while read -r line; do
i=$(($i+1))
echo $i $line
done
and this would control the vlc (from the second terminal)#!/bin/sh
# Use
# control-player.sh vlc [pause|rpause|prev|next|stop]
name="$1"
shift
PATHS="org.mpris.MediaPlayer2.$name /org/mpris/MediaPlayer2"
DBUS_SEND="dbus-send --type=method_call --dest=$PATHS"
RC="$DBUS_SEND org.mpris.MediaPlayer2.Player"
if [ "$@" = "prev" ]; then
$RC.Previous #previous radio station
elif [ "$@" = "rpause" ]; then
$RC.Pause
elif [ "$@" = "stop" ]; then
$RC.Stop
elif [ "$@" = "pause" ]; then
$RC.PlayPause
elif [ "$@" = "next" ]; then
$RC.Next # next radio station
else
echo "Command not found for player $name: $@" 1>&2
exit 1
fi
Right now, I'm exploring what can I do with dbus-send#get Metadata
# dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'
#Open Url
# dbus-send --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri string:"http://relay.181.fm:8068"
#Get Volume
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Volume'
#Set Volume (min 0.0 to max 1.0)
# dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:'org.mpris.MediaPlayer2.Player' string:'Volume' variant:double:0.0
# dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:'org.mpris.MediaPlayer2.Player' string:'Volume' variant:double:1.0
It would be cool if I could catch the signal when Metadata changes. qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2method QString org.freedesktop.DBus.Introspectable.Introspect()
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString, QString)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString)
signal void org.freedesktop.DBus.Properties.PropertiesChanged(QString, QVariantMap, QStringList)
method void org.freedesktop.DBus.Properties.Set(QString, QString, QDBusVariant)
property read bool org.mpris.MediaPlayer2.CanQuit
property read bool org.mpris.MediaPlayer2.CanRaise
property read bool org.mpris.MediaPlayer2.CanSetFullscreen
property read QString org.mpris.MediaPlayer2.DesktopEntry
property readwrite bool org.mpris.MediaPlayer2.Fullscreen
property read bool org.mpris.MediaPlayer2.HasTrackList
property read QString org.mpris.MediaPlayer2.Identity
property read QStringList org.mpris.MediaPlayer2.SupportedMimeTypes
property read QStringList org.mpris.MediaPlayer2.SupportedUriSchemes
method void org.mpris.MediaPlayer2.Quit()
method void org.mpris.MediaPlayer2.Raise()
property read bool org.mpris.MediaPlayer2.Player.CanControl
property read bool org.mpris.MediaPlayer2.Player.CanPause
property read bool org.mpris.MediaPlayer2.Player.CanPlay
property read bool org.mpris.MediaPlayer2.Player.CanSeek
property readwrite QString org.mpris.MediaPlayer2.Player.LoopStatus
property readwrite double org.mpris.MediaPlayer2.Player.MaximumRate
property read QVariantMap org.mpris.MediaPlayer2.Player.Metadata
property readwrite double org.mpris.MediaPlayer2.Player.MinimumRate
property read QString org.mpris.MediaPlayer2.Player.PlaybackStatus
property read int org.mpris.MediaPlayer2.Player.Position
property readwrite double org.mpris.MediaPlayer2.Player.Rate
property readwrite double org.mpris.MediaPlayer2.Player.Shuffle
property readwrite double org.mpris.MediaPlayer2.Player.Volume
method void org.mpris.MediaPlayer2.Player.Next()
method void org.mpris.MediaPlayer2.Player.OpenUri(QString)
method void org.mpris.MediaPlayer2.Player.Pause()
method void org.mpris.MediaPlayer2.Player.Play()
method void org.mpris.MediaPlayer2.Player.PlayPause()
method void org.mpris.MediaPlayer2.Player.Previous()
method void org.mpris.MediaPlayer2.Player.Seek(qlonglong)
method void org.mpris.MediaPlayer2.Player.SetPosition(QDBusObjectPath, qlonglong)
method void org.mpris.MediaPlayer2.Player.Stop()
property read bool org.mpris.MediaPlayer2.TrackList.CanEditTracks
property read QList<QDBusObjectPath> org.mpris.MediaPlayer2.TrackList.Tracks
method void org.mpris.MediaPlayer2.TrackList.AddTrack(QString, QDBusObjectPath, bool)
method QDBusRawType::aa{sv} org.mpris.MediaPlayer2.TrackList.GetTracksMetadata(QList<QDBusObjectPath>)
method void org.mpris.MediaPlayer2.TrackList.GoTo(QDBusObjectPath)
method void org.mpris.MediaPlayer2.TrackList.RemoveTrack(QDBusObjectPath)
signal void org.mpris.MediaPlayer2.TrackList.TrackAdded(QVariantMap, QDBusObjectPath)
signal void org.mpris.MediaPlayer2.TrackList.TrackListReplaced(QList<QDBusObjectPath>, QDBusObjectPath)
signal void org.mpris.MediaPlayer2.TrackList.TrackMetadataChanged(QDBusObjectPath, QVariantMap)
signal void org.mpris.MediaPlayer2.TrackList.TrackRemoved(QDBusObjectPath)
aria2c -x 5 http://www.nixnut.com/vsido/VSIDO_x32_21Oct2016.iso
*** Download Progress Summary as of Thu Oct 27 19:02:30 2016 ***
===============================================================================
[#554950 56MiB/634MiB(8%) CN:5 DL:0.9MiB ETA:9m45s]
I will try to squeeze the install on an old desktop. I'll probably need plop boot to even start.#!/bin/bash
mpg123 --remote --fifo /tmp/pipem --utf8 --title --preload 1 --buffer 768 --smooth &
PID="$!"
if [ ! -e "/tmp/pipem" ]; then
mkfifo /tmp/pipem
fi
sleep 1
function load () {
echo "load http://relay.181.fm:8134" > /tmp/pipem
}
export -f load
function pause () {
echo "pause" > /tmp/pipem
}
export -f pause
function stop () {
echo "stop" > /tmp/pipem
}
export -f stop
yad --form --button "exit!gtk-no:1" \
--field "load:btn" 'bash -c load' \
--field "pause:btn" 'bash -c pause' \
--field "stop:btn" 'bash -c stop'
if [[ $? == 1 || $? == 252 ]]; then
echo stop > /tmp/pipem
kill $PID
rm /tmp/pipem
fi
Hey Misko... downloaded and installed and after updating youtube-dl all is working as advertised... I love the multiple gui options and the ease to switch between themThank you. I've started a new thread > youtube-dl wrapper
Well done!
I recommend you start a new thread with this excellent tool
misko: super awesome addition to youtube-dl and works as advertised, as VastOne pointed out... nice to be able to switch over for multiple downloads.Cheers Z
Thanx!
cheers to all! : )
Z