mb-music dynamic menu big improvements
This commit is contained in:
parent
d31f723478
commit
87fdb0c9f2
288
usr/bin/mb-music
288
usr/bin/mb-music
@ -1,54 +1,190 @@
|
||||
#!/bin/bash
|
||||
# mb-music - play Internet streams with mpv or PyRadio
|
||||
NOWPLAY="$HOME/.config/mabox/.radio-mpv"
|
||||
mkdir -p "$HOME/.config/mabox/mb-music/"
|
||||
|
||||
CONFFILE="$HOME/.config/mabox/mb-music/mb-music.conf" # NOT USED YET
|
||||
# If config file not exist create one with defaults
|
||||
#if [ ! -f $CONFFILE ]; then
|
||||
#cat <<EOF > ${CONFFILE}
|
||||
#
|
||||
#EOF
|
||||
#fi
|
||||
|
||||
# read config variables from file
|
||||
#source <(grep = $CONFFILE)
|
||||
|
||||
PLAYLIST="$HOME/.config/pyradio/stations.csv"
|
||||
PLAYLISTYT="$HOME/.config/mabox/mb-music/yt_music_list.csv"
|
||||
if [ ! -f $PLAYLISTYT ]; then
|
||||
cat <<EOF > ${PLAYLISTYT}
|
||||
Legendary Albums,-
|
||||
Portishead - Dummy 1994,https://www.youtube.com/watch?v=qNq9TJ4QCas
|
||||
R.E.M. - Automatic fot the people 1992,https://www.youtube.com/watch?v=jBUjeOBzkIk
|
||||
Rage Againts The Machine - RATM 1992,https://www.youtube.com/watch?v=MAnsR_7VYKQ
|
||||
Nirvana - Nevermind 1991,https://www.youtube.com/playlist?list=PLFu_yOBZt6G7LbmLmkj4uvs96ZEaH1tja
|
||||
Slayer - South of Heaven 1988,https://www.youtube.com/playlist?list=OLAK5uy_mbXSr6j7jvbIh26_xvtuWqY5Z84BcpxIM
|
||||
Metallica - Master of Puppets 1986,https://www.youtube.com/watch?v=5cSpL4e4uEI
|
||||
The Cure - Faith 1981,https://www.youtube.com/watch?v=fShNf-NdJx4
|
||||
Joy Division - Unknown Pleasures 1979,https://www.youtube.com/watch?v=oo7lt0lLOvg
|
||||
Pink Floyd - The Dark Side Of The Moon 1973,https://www.youtube.com/watch?v=k9ynZnEBtvw
|
||||
Programming music,-
|
||||
Tabnine,https://www.youtube.com/watch?v=L_MupB3z1g4
|
||||
Anonymous Headquarters,https://www.youtube.com/watch?v=Z-VfaG9ZN_U
|
||||
Connection Lost,https://www.youtube.com/watch?v=l9nh1l8ZIJQ
|
||||
Infinity,https://www.youtube.com/watch?v=UoPpxj77Vi0
|
||||
Test Mode,https://www.youtube.com/watch?v=ka4KN2KEGmI
|
||||
Under the Deep,https://www.youtube.com/watch?v=rr0gvSS1OzE
|
||||
Brutal,https://www.youtube.com/watch?v=FS8XtrLqIxw
|
||||
Hidden Service,https://www.youtube.com/watch?v=1-_tyTJHgB8
|
||||
Easy Thoughts,https://www.youtube.com/watch?v=0V7X9fa0wco
|
||||
EOF
|
||||
fi
|
||||
|
||||
NOWPLAY="$HOME/.config/mabox/mb-music/.radio-mpv"
|
||||
NOWPLAYYT="$HOME/.config/mabox/mb-music/.yt-mpv"
|
||||
|
||||
menu() {
|
||||
PLAYLIST="$HOME/.config/pyradio/stations.csv"
|
||||
case $LANG in
|
||||
pl*)
|
||||
SNM="Dźwięk i Muzyka"
|
||||
VOL="Sterowanie głośnością"
|
||||
RADIO="Radio Internetowe"
|
||||
EDITSTATIONS="Edytuj listę stacji"
|
||||
PYRADIO="Uruchom <b>PyRadio</b>"
|
||||
LISTEN="Słuchaj radia..."
|
||||
EDITSTATIONS="Edytuj listę stacji radiowych"
|
||||
RADIOBROWSER="Szukaj stacji online"
|
||||
MPV="Odtwarzaj za pomocą mpv (bez gui)"
|
||||
MPVPLAY="Słuchaj stacji..."
|
||||
MPV="Odtwarzaj (za pomocą mpv - bez gui)"
|
||||
CAVA="Wizualizacja (cava)"
|
||||
STOP="Wyłącz"
|
||||
YTMUSIC="Odtwarzacz MPV"
|
||||
PLAYYT="Odtwarzaj..."
|
||||
EDITPLAYLIST="Edytuj listę"
|
||||
SETTINGS="Ustawienia"
|
||||
;;
|
||||
*)
|
||||
SNM="Sound and Music"
|
||||
VOL="Volume Control"
|
||||
RADIO="Internet Radio"
|
||||
EDITSTATIONS="Edit stations list"
|
||||
PYRADIO="Launch <b>PyRadio</b>"
|
||||
LISTEN="Listen to the radio..."
|
||||
EDITSTATIONS="Edit radio stations list"
|
||||
RADIOBROWSER="Search Radio Stations online"
|
||||
MPV="Play with mpv (no gui)"
|
||||
MPVPLAY="Listen to radio..."
|
||||
MPV="Play (with mpv - no gui)"
|
||||
CAVA="Visualiser (cava)"
|
||||
STOP="Stop"
|
||||
YTMUSIC="MPV Player"
|
||||
PLAYYT="Play..."
|
||||
EDITPLAYLIST="Edit MPV playlist"
|
||||
SETTINGS="Settings"
|
||||
;;
|
||||
esac
|
||||
|
||||
out+=("^sep($VOL)")
|
||||
out+=("Pavucontrol (super+v),pavucontrol")
|
||||
out+=("^sep($SNM)")
|
||||
out+=(" $VOL <span bgcolor='#333333' color='#d3d3d3'> <small>W + v</small> </span>,pavucontrol")
|
||||
out+=("^sep($RADIO)")
|
||||
pgrep -f radio-mpv > /dev/null && NOW="$(<"$NOWPLAY")" out+=("$STOP <i>$NOW</i>,pkill -f radio-mpv") out+=("^sep()")
|
||||
|
||||
out+=("$MPV,^checkout(mpvradio)")
|
||||
out2+=("^tag(mpvradio)")
|
||||
out2+=("^sep($MPVPLAY)")
|
||||
#mapfile -t stations < "$PLAYLIST"
|
||||
while IFS=$'\r\n' read -r line
|
||||
do
|
||||
url=${line#*,}
|
||||
name=${line%,*}
|
||||
out2+=("${name},mb-music play "\""${url}"\"" "\""${name}"\""")
|
||||
done <"$PLAYLIST"
|
||||
out+=("^sep(PyRadio (super+r))")
|
||||
out+=("PyRadio,terminator --geometry=420x440-20-20 -e pyradio")
|
||||
pgrep -f cavatransparent > /dev/null && out+=("$STOP $CAVA,pkill -f cavatransparent") || out+=("$CAVA,transparent-cava")
|
||||
out+=("$PYRADIO <span bgcolor='#333333' color='#d3d3d3'> <small>W + r</small> </span>,terminator --geometry=420x440-20-20 -e pyradio")
|
||||
|
||||
out+=("^sep()")
|
||||
out+=("$EDITSTATIONS,xdg-open $PLAYLIST")
|
||||
out+=("$RADIOBROWSER,xdg-open https://www.radio-browser.info")
|
||||
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") out+=("^sep()")
|
||||
out+=("$LISTEN,^checkout(mpvradio)")
|
||||
out2+=("^tag(mpvradio)")
|
||||
|
||||
out2+=("^sep($LISTEN)")
|
||||
#mapfile -t stations < "$PLAYLIST"
|
||||
grp=0
|
||||
while IFS=$'\r\n' read -r line
|
||||
do
|
||||
url=${line#*,}
|
||||
name=${line%,*}
|
||||
if [ ${url} == "-" ];then
|
||||
((grp++))
|
||||
out2+=("${name},^checkout(${grp})")
|
||||
out3+=("^tag($grp)")
|
||||
out3+=("^sep($name)")
|
||||
else
|
||||
if [ ${grp} != "0" ];then
|
||||
out3+=("<small> ${name}</small>,mb-music play "\""${url}"\"" "\""${name}"\""")
|
||||
else
|
||||
out2+=("<small> ${name}</small>,mb-music play "\""${url}"\"" "\""${name}"\""")
|
||||
fi
|
||||
fi
|
||||
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLIST)
|
||||
|
||||
|
||||
|
||||
|
||||
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" "^sep()")
|
||||
|
||||
n=$(grep -v '^\s*$\|^#\|^\s*#' ${PLAYLISTYT} |wc -l)
|
||||
|
||||
### List yt playlist
|
||||
if (( $n <= 24 ));then #flat view in rootmenu
|
||||
while IFS=$'\r\n' read -r line
|
||||
do
|
||||
url=${line#*,}
|
||||
name=${line%,*}
|
||||
if [ ${url} == "-" ];then
|
||||
out+=("^sep(<small>$name</small>)")
|
||||
else
|
||||
[[ $name != "" ]] && out+=("<small> ${name}</small>,mb-music playyt "\""${url}"\"" "\""${name}"\""")
|
||||
fi
|
||||
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
||||
elif (( $n <= 30 ));then # flat view in submenu
|
||||
out+=("$PLAYYT ,^checkout(ytmusic)")
|
||||
out2+=("^tag(ytmusic)")
|
||||
out2+=("^sep($YTMUSIC)")
|
||||
grp=0
|
||||
while IFS=$'\r\n' read -r line
|
||||
do
|
||||
url=${line#*,}
|
||||
name=${line%,*}
|
||||
if [ ${url} == "-" ];then
|
||||
out2+=("^sep(<small>$name</small>)")
|
||||
else
|
||||
[[ $name != "" ]] && out2+=("<small> ${name}</small>,mb-music playyt "\""${url}"\"" "\""${name}"\""")
|
||||
fi
|
||||
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
||||
out2+=("^sep()")
|
||||
out2+=("$EDITPLAYLIST,xdg-open $PLAYLISTYT")
|
||||
else # n > 30
|
||||
out+=("$PLAYYT ,^checkout(ytmusic)")
|
||||
out2+=("^tag(ytmusic)")
|
||||
out2+=("^sep($YTMUSIC)")
|
||||
grp=0
|
||||
while IFS=$'\r\n' read -r line
|
||||
do
|
||||
url=${line#*,}
|
||||
name=${line%,*}
|
||||
if [ ${url} == "-" ];then
|
||||
((grp++))
|
||||
out2+=("${name},^checkout(yt${grp})")
|
||||
out3+=("^tag(yt$grp)")
|
||||
out3+=("^sep($name)")
|
||||
else
|
||||
if [ ${grp} != "0" ];then
|
||||
out3+=(" ${name},mb-music playyt "\""${url}"\"" "\""${name}"\""")
|
||||
else
|
||||
out2+=(" ${name},mb-music playyt "\""${url}"\"" "\""${name}"\""")
|
||||
fi
|
||||
fi
|
||||
done <<< $(grep -v '^\s*$\|^#\|^\s*#' $PLAYLISTYT)
|
||||
|
||||
fi
|
||||
|
||||
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")
|
||||
|
||||
out+=("^sep()")
|
||||
out+=(" $SETTINGS,^checkout(settings)")
|
||||
out2+=("^tag(settings)")
|
||||
out2+=("^sep($RADIO)")
|
||||
out2+=(" $EDITSTATIONS,xdg-open $PLAYLIST")
|
||||
out2+=(" $RADIOBROWSER,xdg-open https://www.radio-browser.info")
|
||||
out2+=("^sep($YTMUSIC)")
|
||||
out2+=(" $EDITPLAYLIST,xdg-open $PLAYLISTYT")
|
||||
|
||||
### RUN
|
||||
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
|
||||
@ -61,12 +197,12 @@ elif [[ $panels_heightpos == "bottom" ]]; then
|
||||
MENU_VALIGN="bottom"
|
||||
MENU_MARGIN_Y=${panels_topmargin:-0}
|
||||
else
|
||||
MENU_VALIGN="center"
|
||||
MENU_VALIGN="top"
|
||||
fi
|
||||
|
||||
MENU_PADDING_TOP=${jgtools_padding:-0}
|
||||
MENU_HALIGN="left"
|
||||
JGWIDTH=320
|
||||
MENU_PADDING_TOP=$((jgtools_padding+102))
|
||||
MENU_HALIGN="right"
|
||||
JGWIDTH=$((300+2*jgtools_padding))
|
||||
|
||||
if [[ "$1" == "ipc" ]]; then
|
||||
POSITION_MODE="ipc"
|
||||
@ -79,36 +215,112 @@ jgmenu_icon_size=0
|
||||
[ -z $jgmenu_use_borders ] && menu_border=0
|
||||
|
||||
mkconfigfile
|
||||
|
||||
if [[ "$NOWPL" == "1" ]];then
|
||||
clr="#22FF22"
|
||||
read -r -d '' NOWPLAYLINES <<EOF
|
||||
@rect,,${jgtools_padding},$((jgtools_padding+74)),300,24,0,left,top,,#222222 80,
|
||||
@rect,,$((jgtools_padding+16)),$((jgtools_padding+78)),$((JGWIDTH-2*jgtools_padding-32)),16,4,left,top,,#222222 85,
|
||||
@text,,$((jgtools_padding+18)),$((jgtools_padding+76)),$((JGWIDTH-2*jgtools_padding)),20,0,left,top,#FFFFFF 90,,""" <small>${NOW}</small>"""
|
||||
EOF
|
||||
else
|
||||
clr="#333333"
|
||||
fi
|
||||
|
||||
cat <<EOF > ${MENU_ITEMS}
|
||||
@rect,,${jgtools_padding},${jgtools_padding},300,100,0,left,top,,#222222 35,
|
||||
|
||||
@rect,,${jgtools_padding},$((jgtools_padding+64)),8,36,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+10)),$((jgtools_padding+70)),8,30,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+20)),$((jgtools_padding+44)),8,56,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+30)),$((jgtools_padding+56)),8,44,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+40)),$((jgtools_padding+64)),8,36,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+50)),$((jgtools_padding+54)),8,46,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+60)),$((jgtools_padding+14)),8,86,0,left,top,,${clr} 100,
|
||||
@rect,,$((jgtools_padding+70)),$((jgtools_padding+29)),8,71,0,left,top,,${clr} 95,
|
||||
@rect,,$((jgtools_padding+80)),$((jgtools_padding+64)),8,36,0,left,top,,${clr} 90,
|
||||
@rect,,$((jgtools_padding+90)),$((jgtools_padding+74)),8,26,0,left,top,,${clr} 85,
|
||||
@rect,,$((jgtools_padding+100)),$((jgtools_padding+54)),8,46,0,left,top,,${clr} 80,
|
||||
@rect,,$((jgtools_padding+110)),$((jgtools_padding+24)),8,76,0,left,top,,${clr} 75,
|
||||
@rect,,$((jgtools_padding+120)),$((jgtools_padding+34)),8,66,0,left,top,,${clr} 70,
|
||||
@rect,,$((jgtools_padding+130)),$((jgtools_padding+44)),8,56,0,left,top,,${clr} 65,
|
||||
@rect,,$((jgtools_padding+140)),$((jgtools_padding+54)),8,46,0,left,top,,${clr} 60,
|
||||
@rect,,$((jgtools_padding+150)),$((jgtools_padding+74)),8,26,0,left,top,,${clr} 55,
|
||||
@rect,,$((jgtools_padding+160)),$((jgtools_padding+84)),8,16,0,left,top,,${clr} 50,
|
||||
@rect,,$((jgtools_padding+170)),$((jgtools_padding+89)),8,11,0,left,top,,${clr} 45,
|
||||
@rect,,$((jgtools_padding+180)),$((jgtools_padding+94)),8,6,0,left,top,,${clr} 40,
|
||||
@rect,,$((jgtools_padding+190)),$((jgtools_padding+95)),8,5,0,left,top,,${clr} 35,
|
||||
@rect,,$((jgtools_padding+200)),$((jgtools_padding+95)),8,5,0,left,top,,${clr} 30,
|
||||
@rect,,$((jgtools_padding+210)),$((jgtools_padding+95)),8,5,0,left,top,,${clr} 25,
|
||||
@rect,,$((jgtools_padding+220)),$((jgtools_padding+96)),8,4,0,left,top,,${clr} 20,
|
||||
@rect,,$((jgtools_padding+230)),$((jgtools_padding+96)),8,4,0,left,top,,${clr} 15,
|
||||
|
||||
@rect,,$((jgtools_padding+260)),$((jgtools_padding+94)),8,6,0,left,top,,${clr} 40,
|
||||
@rect,,$((jgtools_padding+270)),$((jgtools_padding+68)),8,32,0,left,top,,${clr} 50,
|
||||
@rect,,$((jgtools_padding+280)),$((jgtools_padding+64)),8,36,0,left,top,,${clr} 60,
|
||||
@rect,,$((jgtools_padding+290)),$((jgtools_padding+58)),8,42,0,left,top,,${clr} 80,
|
||||
|
||||
|
||||
${NOWPLAYLINES}
|
||||
|
||||
$(printf '%s\n' "${out0[@]}")
|
||||
$(printf '%s\n' "${out[@]}")
|
||||
$(printf '%s\n' "${out2[@]}")
|
||||
$(printf '%s\n' "${out3[@]}")
|
||||
EOF
|
||||
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "${out0[@]}"
|
||||
printf '%s\n' "${out[@]}"
|
||||
|
||||
#if [[ $1 == "-r" ]]; then # not used
|
||||
#printf '%s\n' "^sep()"
|
||||
#printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgdesktops=false;mb-jgtools places"
|
||||
#fi
|
||||
printf '%s\n' "${out2[@]}"
|
||||
printf '%s\n' "${out3[@]}"
|
||||
}
|
||||
|
||||
play() {
|
||||
pkill -f radio-mpv
|
||||
pkill -f yt-mpv
|
||||
notify-send.sh "Playing now: " "$3" --icon=media-tape &
|
||||
echo "$3" > "$NOWPLAY"
|
||||
mpv --title=radio-mpv "$2"
|
||||
mpv --title=radio-mpv "$2" --input-ipc-server=/tmp/mpvsocket
|
||||
}
|
||||
playyt() {
|
||||
pkill -f yt-mpv
|
||||
pkill -f radio-mpv
|
||||
notify-send.sh "Playing now: " "$3" --icon=media-tape &
|
||||
echo "$3" > "$NOWPLAYYT"
|
||||
if [[ "$2" == *"playlist"* ]];then
|
||||
mpv --ytdl-raw-options="yes-playlist=" "$2" --no-video --title=yt-mpv --input-ipc-server=/tmp/mpvsocket
|
||||
else
|
||||
mpv "$2" --no-video --title=yt-mpv --input-ipc-server=/tmp/mpvsocket
|
||||
fi
|
||||
}
|
||||
|
||||
# Not really used
|
||||
stop() {
|
||||
stopyt
|
||||
pkill -f radio-mpv
|
||||
echo "" > "$NOWPLAY"
|
||||
}
|
||||
|
||||
stopyt() {
|
||||
stop
|
||||
pkill -f yt-mpv
|
||||
echo "" > "$NOWPLAYYT"
|
||||
}
|
||||
cavastart() {
|
||||
cavakill
|
||||
transparent-cava ${1} ${2} &2>/dev/null &
|
||||
}
|
||||
cavakill() {
|
||||
pkill -f cavatransparent &
|
||||
}
|
||||
case "$1" in
|
||||
play) play "$1" "$2" "$3";;
|
||||
playyt) playyt "$1" "$2" "$3";;
|
||||
stop) stop;;
|
||||
stopyt) stopyt;;
|
||||
cavastart) cavastart "$2" "$3";;
|
||||
cavakill) cavakill;;
|
||||
ipc|*) menu "$1";;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user