mb-music menu

master
Daniel Napora 2021-11-17 13:06:29 +01:00
parent 91c42e3d46
commit a9e35bce0f
2 changed files with 111 additions and 11 deletions

104
usr/bin/mb-music 100755
View File

@ -0,0 +1,104 @@
#!/bin/bash
# mb-music - play Internet streams with mpv or PyRadio
NOWPLAY="$HOME/.config/mabox/.radio-mpv"
menu() {
PLAYLIST="$HOME/.config/pyradio/stations.csv"
case $LANG in
pl*)
VOL="Sterowanie głośnością"
RADIO="Radio Internetowe"
EDITSTATIONS="Edytuj listę stacji"
RADIOBROWSER="Szukaj stacji online"
;;
*)
VOL="Volume Control"
RADIO="Internet Radio"
EDITSTATIONS="Edit stations list"
RADIOBROWSER="Search Radio Stations online"
;;
esac
out+=("^sep($VOL)")
out+=("Pavucontrol (super+v),pavucontrol")
out+=("^sep($RADIO)")
pgrep -f radio-mpv > /dev/null && NOW="$(<"$NOWPLAY")" out+=("Stop <i>$NOW</i>,pkill -f radio-mpv") out+=("^sep()")
out+=("Play with mpv (no gui),^checkout(mpvradio)")
out2+=("^tag(mpvradio)")
#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")
out+=("Cava,terminator --geometry=420x200-460-20 -e cava")
out+=("^sep()")
out+=("$EDITSTATIONS,xdg-open $PLAYLIST")
out+=("$RADIOBROWSER,xdg-open https://www.radio-browser.info")
### RUN
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
if [[ $panels_heightpos == "top" ]]; then
MENU_VALIGN="top"
MENU_MARGIN_Y=${panels_topmargin:-0}
elif [[ $panels_heightpos == "bottom" ]]; then
MENU_VALIGN="bottom"
MENU_MARGIN_Y=${panels_topmargin:-0}
else
MENU_VALIGN="center"
fi
MENU_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="left"
JGWIDTH=320
if [[ "$1" == "ipc" ]]; then
POSITION_MODE="ipc"
else
POSITION_MODE="fixed"
fi
jgmenu_icon_size=0
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
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[@]}"
}
play() {
pkill -f radio-mpv
notify-send.sh "Playing now: " "$3" --icon=media-tape &
echo "$3" > "$NOWPLAY"
mpv --title=radio-mpv "$2"
}
stop() {
pkill -f radio-mpv
echo "" > "$NOWPLAY"
}
case "$1" in
play) play "$1" "$2" "$3";;
stop) stop;;
ipc|*) menu "$1";;
esac

View File

@ -28,12 +28,6 @@ else
out2+=("$INST Firefox,pamac-installer firefox,package-manager-icon")
fi
if hash brave &>/dev/null; then
out+=("Brave,Brave,brave")
else
out2+=("$INST Brave,pamac-installer brave,package-manager-icon")
fi
if hash chromium &>/dev/null; then
out+=("Chromium,chromium,chromium")
else out2+=("$INST Chromium,pamac-installer chromium,package-manager-icon")
@ -48,6 +42,11 @@ if hash opera &>/dev/null; then
out+=("Opera,opera,opera")
else out2+=("$INST Opera,pamac-installer opera,package-manager-icon")
fi
if hash brave &>/dev/null; then
out+=("Brave,Brave,brave")
else
out2+=("$INST Brave,pamac-installer brave,package-manager-icon")
fi
if hash qutebrowser &>/dev/null; then
out+=("Qutebrowser,qutebrowser,qutebrowser")
else out2+=("$INST Qutebrowser,pamac-installer qutebrowser,package-manager-icon")
@ -93,20 +92,17 @@ fi
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"
if [[ $1 == "-r" ]]; then
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