Added new mediaplayer script for waybar

This commit is contained in:
Marko Korhonen 2020-04-07 13:29:13 +03:00
parent aa84653a5c
commit 5983c567de
10 changed files with 142 additions and 234 deletions

View file

@ -3,13 +3,7 @@
MPVPIPE=/tmp/mpvqueue.playlist
notify="notify-send -i mpv -a mpv"
# if link is a youtube playlist, clean up url
if [[ ${1} =~ /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$ ]]; then
url="https://youtube.com/playlist?list=${1#*list=}"
else
url="$1"
fi
url="$1"
# See if MPV is already running
if [ -z "$(pidof mpv)" ]; then
@ -17,6 +11,9 @@ if [ -z "$(pidof mpv)" ]; then
# remove fifo
rm -f $MPVPIPE && mkfifo $MPVPIPE
# pause other players
playerctl pause
# start mpv
/usr/bin/mpv --no-terminal --input-file="${MPVPIPE}" "$url" & disown