initial commit
This commit is contained in:
commit
2822d47a17
27
mpv-add.sh
Executable file
27
mpv-add.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
URL="${1:-$(wl-paste -p)}"
|
||||||
|
MPV_SOCKET=/tmp/mpvsocket
|
||||||
|
|
||||||
|
if [[ -z "$URL" ]]; then
|
||||||
|
notify-send -i mpv "No URL provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ -f "$URL" ]] && ! yt-dlp --simulate "$URL"; then
|
||||||
|
notify-send -i mpv "Invalid URL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! pgrep -x mpv &>/dev/null; then
|
||||||
|
mpv "$URL" &>/dev/null &
|
||||||
|
notify-send -i mpv "Playing $URL"
|
||||||
|
else
|
||||||
|
if echo "{ \"command\": [\"script-message\", \"add_to_queue\", \"$URL\" ] }" | socat - "$MPV_SOCKET" &>/dev/null; then
|
||||||
|
notify-send -i mpv "Added $URL to queue"
|
||||||
|
else
|
||||||
|
notify-send -i mpv "Failed to add $URL to queue"
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user