mb-music
parent
ce82f3ffcc
commit
15cc931155
171
usr/bin/mb-music
171
usr/bin/mb-music
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# mb-music - play Internet streams with mpv or PyRadio
|
# mb-music - play Internet streams with mpv or PyRadio
|
||||||
|
me="${0##*/} ipc"
|
||||||
|
|
||||||
wmctrl -R cavatransparent
|
wmctrl -R cavatransparent
|
||||||
mkdir -p "$HOME/.config/mabox/mb-music/"
|
mkdir -p "$HOME/.config/mabox/mb-music/"
|
||||||
|
|
||||||
|
@ -43,59 +45,73 @@ NOWPLAYYT="$HOME/.config/mabox/mb-music/.yt-mpv"
|
||||||
menu() {
|
menu() {
|
||||||
case $LANG in
|
case $LANG in
|
||||||
pl*)
|
pl*)
|
||||||
SNM="Dźwięk i Muzyka"
|
_SNM="<b>Dźwięk i Muzyka</b>"
|
||||||
VOL="Sterowanie głośnością"
|
_VOL="Sterowanie głośnością"
|
||||||
RADIO="Radio Internetowe"
|
_RADIO="Radio Internetowe"
|
||||||
PYRADIO="Uruchom <b>PyRadio</b>"
|
_PYRADIO="Uruchom <b>PyRadio</b>"
|
||||||
LISTEN="Słuchaj radia..."
|
_LISTEN="Słuchaj radia..."
|
||||||
EDITSTATIONS="Edytuj listę stacji radiowych"
|
_EDITSTATIONS="Edytuj listę stacji radiowych"
|
||||||
RADIOBROWSER="Szukaj stacji online"
|
_RADIOBROWSER="Szukaj stacji online"
|
||||||
MPV="Odtwarzaj (za pomocą mpv - bez gui)"
|
_MPV="Odtwarzaj (za pomocą mpv - bez gui)"
|
||||||
CAVA="Wizualizacja (cava)"
|
_CAVA="Wizualizacja (cava)"
|
||||||
STOP="Wyłącz"
|
_STOP="Wyłącz"
|
||||||
YTMUSIC="Odtwarzacz MPV"
|
_PAUSE="Pauza"
|
||||||
PLAYYT="Odtwarzaj..."
|
_PLAY="Graj"
|
||||||
EDITPLAYLIST="Edytuj listę"
|
_YTMUSIC="Odtwarzacz MPV"
|
||||||
SETTINGS="Ustawienia"
|
_PLAYYT="Odtwarzaj..."
|
||||||
|
_EDITPLAYLIST="Edytuj listę"
|
||||||
|
_SETTINGS="Ustawienia"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
SNM="Sound and Music"
|
_SNM="<b>Music & Sound</b> Menu"
|
||||||
VOL="Volume Control"
|
_VOL="Volume Control"
|
||||||
RADIO="Internet Radio"
|
_RADIO="Internet Radio"
|
||||||
PYRADIO="Launch <b>PyRadio</b>"
|
_PYRADIO="Launch <b>PyRadio</b>"
|
||||||
LISTEN="Listen to the radio..."
|
_LISTEN="Listen to the radio..."
|
||||||
EDITSTATIONS="Edit radio stations list"
|
_EDITSTATIONS="Edit radio stations list"
|
||||||
RADIOBROWSER="Search Radio Stations online"
|
_RADIOBROWSER="Search Radio Stations online"
|
||||||
MPV="Play (with mpv - no gui)"
|
_MPV="Play (with mpv - no gui)"
|
||||||
CAVA="Visualiser (cava)"
|
_CAVA="Visualiser (cava)"
|
||||||
STOP="Stop"
|
_STOP="Quit"
|
||||||
YTMUSIC="MPV Player"
|
_PAUSE="Pause"
|
||||||
PLAYYT="Play..."
|
_PLAY="Play"
|
||||||
EDITPLAYLIST="Edit MPV playlist"
|
_YTMUSIC="MPV Player"
|
||||||
SETTINGS="Settings"
|
_PLAYYT="Play..."
|
||||||
|
_EDITPLAYLIST="Edit MPV playlist"
|
||||||
|
_SETTINGS="Settings"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
out+=("^sep($SNM)")
|
#out+=("^sep($_SNM)")
|
||||||
out+=(" $VOL <span bgcolor='#333333' color='#d3d3d3'> <small>W + v</small> </span>,pavucontrol")
|
out+=(" $_VOL <span bgcolor='#333333' color='#d3d3d3'> <small> + v</small> </span>,pavucontrol")
|
||||||
out+=("^sep($RADIO)")
|
out+=("^sep($_RADIO)")
|
||||||
out+=("$PYRADIO <span bgcolor='#333333' color='#d3d3d3'> <small>W + r</small> </span>,terminator --icon=/usr/share/icons/pyradio.png --geometry=564x440-20-20 -x pyradio -lt")
|
out+=("$_PYRADIO <span bgcolor='#333333' color='#d3d3d3'> <small> + r</small> </span>,terminator --icon=/usr/share/icons/pyradio.png --geometry=564x440-20-20 -x pyradio -lt")
|
||||||
|
|
||||||
out+=("^sep()")
|
out+=("^sep()")
|
||||||
NOWPL="0"
|
NOWPL="0"
|
||||||
|
|
||||||
pgrep -f radio-mpv > /dev/null && NOW="$(<"$NOWPLAY")" NOWPL="1" out0+=("<small> $STOP <i>$NOW</i></small>,pkill -f radio-mpv;pkill -f yt-mpv")
|
#pgrep -f radio-mpv > /dev/null && NOW="$(<"$NOWPLAY")" NOWPL="1" out0+=("<small> $STOP <i>$NOW</i></small>,pkill -f radio-mpv;pkill -f yt-mpv")
|
||||||
out+=("$LISTEN,^checkout(mpvradio)")
|
|
||||||
|
if pgrep -f radio-mpv > /dev/null
|
||||||
|
then
|
||||||
|
status="$(playerctl -p mpv status)"
|
||||||
|
NOW="$(<"$NOWPLAY")" NOWPL="1"
|
||||||
|
[[ "$status" == "Playing" ]] && out0+=(" <small>$_PAUSE</small>,playerctl -p mpv pause;${me}") || out0+=(" <small>$_PLAY</small>,playerctl -p mpv play;${me}")
|
||||||
|
out0+=(" <small>$_STOP</small>,pkill -f yt-mpv;pkill -f radio-mpv")
|
||||||
|
out0+=("^sep()")
|
||||||
|
fi
|
||||||
|
|
||||||
|
out+=("$_LISTEN,^checkout(mpvradio)")
|
||||||
out2+=("^tag(mpvradio)")
|
out2+=("^tag(mpvradio)")
|
||||||
|
|
||||||
out2+=("^sep($LISTEN)")
|
out2+=("^sep($_LISTEN)")
|
||||||
#mapfile -t stations < "$PLAYLIST"
|
#mapfile -t stations < "$PLAYLIST"
|
||||||
grp=0
|
grp=0
|
||||||
while IFS=$'\r\n' read -r line
|
while IFS=$'\r\n' read -r line
|
||||||
do
|
do
|
||||||
url=${line#*,}
|
url=${line#*,}
|
||||||
name=${line%,*}
|
name=${line%,*}
|
||||||
if [ ${url} == "-" ];then
|
if [[ "${url}" == "-" ]];then
|
||||||
((grp++))
|
((grp++))
|
||||||
out2+=("${name},^checkout(${grp})")
|
out2+=("${name},^checkout(${grp})")
|
||||||
out3+=("^tag($grp)")
|
out3+=("^tag($grp)")
|
||||||
|
@ -112,8 +128,16 @@ done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLIST)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
out+=("^sep($YTMUSIC)")
|
out+=("^sep($_YTMUSIC)")
|
||||||
pgrep -f yt-mpv > /dev/null && NOW="$(<"$NOWPLAYYT")" NOWPL="1" out0+=("<small> $STOP <i>$NOW</i></small>,pkill -f yt-mpv;pkill -f radio-mpv")
|
#pgrep -f yt-mpv > /dev/null && NOW="$(<"$NOWPLAYYT")" NOWPL="1" out0+=("<small> $STOP <i>$NOW</i></small>,pkill -f yt-mpv;pkill -f radio-mpv")
|
||||||
|
if pgrep -f yt-mpv > /dev/null
|
||||||
|
then
|
||||||
|
status="$(playerctl -p mpv status)"
|
||||||
|
NOW="$(<"$NOWPLAYYT")" NOWPL="1"
|
||||||
|
[[ "$status" == "Playing" ]] && out0+=(" <small>$_PAUSE</small>,playerctl -p mpv pause;${me}") || out0+=(" <small>$_PLAY</small>,playerctl -p mpv play;${me}")
|
||||||
|
out0+=(" <small>$_STOP</small>,pkill -f yt-mpv;pkill -f radio-mpv")
|
||||||
|
out0+=("^sep()")
|
||||||
|
fi
|
||||||
|
|
||||||
n=$(grep -v '^\s*$\|^#\|^\s*#' ${PLAYLISTYT} |wc -l)
|
n=$(grep -v '^\s*$\|^#\|^\s*#' ${PLAYLISTYT} |wc -l)
|
||||||
|
|
||||||
|
@ -130,9 +154,9 @@ if (( $n <= 24 ));then #flat view in rootmenu
|
||||||
fi
|
fi
|
||||||
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
||||||
elif (( $n <= 30 ));then # flat view in submenu
|
elif (( $n <= 30 ));then # flat view in submenu
|
||||||
out+=("$PLAYYT ,^checkout(ytmusic)")
|
out+=("$_PLAYYT ,^checkout(ytmusic)")
|
||||||
out2+=("^tag(ytmusic)")
|
out2+=("^tag(ytmusic)")
|
||||||
out2+=("^sep($YTMUSIC)")
|
out2+=("^sep($_YTMUSIC)")
|
||||||
grp=0
|
grp=0
|
||||||
while IFS=$'\r\n' read -r line
|
while IFS=$'\r\n' read -r line
|
||||||
do
|
do
|
||||||
|
@ -145,11 +169,11 @@ elif (( $n <= 30 ));then # flat view in submenu
|
||||||
fi
|
fi
|
||||||
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
||||||
out2+=("^sep()")
|
out2+=("^sep()")
|
||||||
out2+=("$EDITPLAYLIST,xdg-open $PLAYLISTYT")
|
out2+=("$_EDITPLAYLIST,xdg-open $PLAYLISTYT")
|
||||||
else # n > 30
|
else # n > 30
|
||||||
out+=("$PLAYYT ,^checkout(ytmusic)")
|
out+=("$_PLAYYT ,^checkout(ytmusic)")
|
||||||
out2+=("^tag(ytmusic)")
|
out2+=("^tag(ytmusic)")
|
||||||
out2+=("^sep($YTMUSIC)")
|
out2+=("^sep($_YTMUSIC)")
|
||||||
grp=0
|
grp=0
|
||||||
while IFS=$'\r\n' read -r line
|
while IFS=$'\r\n' read -r line
|
||||||
do
|
do
|
||||||
|
@ -172,16 +196,16 @@ else # n > 30
|
||||||
fi
|
fi
|
||||||
|
|
||||||
out+=("^sep(VISUALIZER)")
|
out+=("^sep(VISUALIZER)")
|
||||||
pgrep -f cavatransparent > /dev/null && out+=("$STOP $CAVA,mb-music cavakill;mb-music ipc" "Colorize Cava,colorizer-cava -s") || out+=(" $CAVA,mb-music cavastart;mb-music ipc")
|
pgrep -f cavatransparent > /dev/null && out+=("$_STOP $_CAVA,mb-music cavakill;mb-music ipc" "Colorize Cava,colorizer-cava -s") || out+=(" $_CAVA,mb-music cavastart;mb-music ipc")
|
||||||
|
|
||||||
out+=("^sep()")
|
out+=("^sep()")
|
||||||
out+=(" $SETTINGS,^checkout(settings)")
|
out+=(" $_SETTINGS,^checkout(settings)")
|
||||||
out2+=("^tag(settings)")
|
out2+=("^tag(settings)")
|
||||||
out2+=("^sep($RADIO)")
|
out2+=("^sep($_RADIO)")
|
||||||
out2+=(" $EDITSTATIONS,xdg-open $PLAYLIST")
|
out2+=(" $_EDITSTATIONS,xdg-open $PLAYLIST")
|
||||||
out2+=(" $RADIOBROWSER,xdg-open https://www.radio-browser.info")
|
out2+=(" $_RADIOBROWSER,xdg-open https://www.radio-browser.info")
|
||||||
out2+=("^sep($YTMUSIC)")
|
out2+=("^sep($_YTMUSIC)")
|
||||||
out2+=(" $EDITPLAYLIST,xdg-open $PLAYLISTYT")
|
out2+=(" $_EDITPLAYLIST,xdg-open $PLAYLISTYT")
|
||||||
|
|
||||||
### RUN
|
### RUN
|
||||||
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
|
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
|
||||||
|
@ -194,7 +218,8 @@ elif [[ $panels_heightpos == "bottom" ]]; then
|
||||||
MENU_VALIGN="bottom"
|
MENU_VALIGN="bottom"
|
||||||
MENU_MARGIN_Y=${panels_topmargin:-0}
|
MENU_MARGIN_Y=${panels_topmargin:-0}
|
||||||
else
|
else
|
||||||
MENU_VALIGN="top"
|
MENU_VALIGN="center"
|
||||||
|
menu_margin_x=4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MENU_PADDING_TOP=$((jgtools_padding+102))
|
MENU_PADDING_TOP=$((jgtools_padding+102))
|
||||||
|
@ -217,32 +242,36 @@ mkconfigfile
|
||||||
if [[ "$NOWPL" == "1" ]];then
|
if [[ "$NOWPL" == "1" ]];then
|
||||||
clr="#22FF22"
|
clr="#22FF22"
|
||||||
read -r -d '' NOWPLAYLINES <<EOF
|
read -r -d '' NOWPLAYLINES <<EOF
|
||||||
@rect,,${jgtools_padding},$((jgtools_padding+74)),300,24,0,left,top,,#222222 80,
|
#@rect,,${jgtools_padding},$((jgtools_padding+74)),298,24,0,left,top,,#222222 60,
|
||||||
@rect,,$((jgtools_padding+16)),$((jgtools_padding+78)),$((JGWIDTH-2*jgtools_padding-32)),16,4,left,top,,#222222 25,
|
@rect,,$((jgtools_padding+16)),$((jgtools_padding+70)),$((JGWIDTH-2*jgtools_padding-32)),20,4,left,top,,#222222 75,
|
||||||
@text,,$((jgtools_padding+18)),$((jgtools_padding+76)),$((JGWIDTH-2*jgtools_padding)),20,0,left,top,#FFFFFF 90,,""" <small>${NOW}</small>"""
|
@text,,$((jgtools_padding+20)),$((jgtools_padding+70)),$((JGWIDTH-2*jgtools_padding)),20,0,left,top,#FFFFFF 90,,""" <small>${NOW}</small>"""
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
clr="#444444"
|
clr="#666666"
|
||||||
|
read -r -d '' NOWPLAYLINES <<EOF
|
||||||
|
@rect,,$((jgtools_padding+2)),$((jgtools_padding+72)),296,24,0,left,top,,#222222 70,
|
||||||
|
@text,,$((jgtools_padding+6)),$((jgtools_padding+74)),$((JGWIDTH-2*jgtools_padding)),20,0,left,top,#FFFFFF 90,,""" ${_SNM} <span bgcolor='#333333' color='#d3d3d3'> <small> + m</small> </span>"""
|
||||||
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat <<EOF > ${MENU_ITEMS}
|
cat <<EOF > ${MENU_ITEMS}
|
||||||
@rect,,${jgtools_padding},${jgtools_padding},300,100,0,left,top,,#ffffff 15,
|
@rect,,${jgtools_padding},${jgtools_padding},300,100,4,left,top,,#111111 25,
|
||||||
|
|
||||||
@rect,,${jgtools_padding},$((jgtools_padding+64)),18,36,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+1)),$((jgtools_padding+63)),18,36,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+20)),$((jgtools_padding+44)),18,56,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+21)),$((jgtools_padding+43)),18,56,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+40)),$((jgtools_padding+64)),18,36,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+41)),$((jgtools_padding+38)),18,61,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+60)),$((jgtools_padding+14)),18,86,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+61)),$((jgtools_padding+13)),18,86,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+80)),$((jgtools_padding+64)),18,36,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+81)),$((jgtools_padding+43)),18,56,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+100)),$((jgtools_padding+54)),18,46,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+101)),$((jgtools_padding+53)),18,46,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+120)),$((jgtools_padding+34)),18,66,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+121)),$((jgtools_padding+33)),18,66,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+140)),$((jgtools_padding+54)),18,46,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+141)),$((jgtools_padding+53)),18,46,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+160)),$((jgtools_padding+84)),18,16,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+161)),$((jgtools_padding+83)),18,16,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+180)),$((jgtools_padding+94)),18,6,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+181)),$((jgtools_padding+93)),18,6,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+200)),$((jgtools_padding+95)),18,5,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+201)),$((jgtools_padding+97)),18,2,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+220)),$((jgtools_padding+96)),18,4,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+221)),$((jgtools_padding+86)),18,13,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+240)),$((jgtools_padding+81)),18,19,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+241)),$((jgtools_padding+80)),18,19,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+260)),$((jgtools_padding+90)),18,10,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+261)),$((jgtools_padding+58)),18,41,2,left,top,,${clr} 100,
|
||||||
@rect,,$((jgtools_padding+280)),$((jgtools_padding+64)),18,36,0,left,top,,${clr} 100,
|
@rect,,$((jgtools_padding+281)),$((jgtools_padding+43)),18,56,2,left,top,,${clr} 100,
|
||||||
|
|
||||||
${NOWPLAYLINES}
|
${NOWPLAYLINES}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue