add title to notifications
This commit is contained in:
parent
0a82495aaf
commit
8edff9d3aa
11
mpv-add.sh
11
mpv-add.sh
@ -5,24 +5,25 @@ set -Eeuo pipefail
|
|||||||
URL="${1:-$(wl-paste -p)}"
|
URL="${1:-$(wl-paste -p)}"
|
||||||
MPV_SOCKET=/tmp/mpvsocket
|
MPV_SOCKET=/tmp/mpvsocket
|
||||||
ICON_PATH="$HOME/.local/share/icons/Magna-Glassy-Dark-Icons/apps/48/mpv.svg"
|
ICON_PATH="$HOME/.local/share/icons/Magna-Glassy-Dark-Icons/apps/48/mpv.svg"
|
||||||
|
TITLE="mpv-add.sh"
|
||||||
|
|
||||||
if [[ -z "$URL" ]]; then
|
if [[ -z "$URL" ]]; then
|
||||||
notify-send -i "$ICON_PATH" "No URL provided"
|
notify-send -i "$ICON_PATH" "$TITLE" "No URL provided"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ -f "$URL" ]] && ! yt-dlp --simulate "$URL"; then
|
if ! [[ -f "$URL" ]] && ! yt-dlp --simulate "$URL"; then
|
||||||
notify-send -i "$ICON_PATH" "Invalid URL"
|
notify-send -i "$ICON_PATH" "$TITLE" "Invalid URL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! pgrep -x mpv &> /dev/null; then
|
if ! pgrep -x mpv &> /dev/null; then
|
||||||
mpv "$URL" &> /dev/null &
|
mpv "$URL" &> /dev/null &
|
||||||
notify-send -i "$ICON_PATH" "Playing $URL"
|
notify-send -i "$ICON_PATH" "$TITLE" "Playing $URL"
|
||||||
else
|
else
|
||||||
if echo "{ \"command\": [\"script-message\", \"add_to_queue\", \"$URL\" ] }" | socat - "$MPV_SOCKET" &> /dev/null; then
|
if echo "{ \"command\": [\"script-message\", \"add_to_queue\", \"$URL\" ] }" | socat - "$MPV_SOCKET" &> /dev/null; then
|
||||||
notify-send -i "$ICON_PATH" "Added $URL to queue"
|
notify-send -i "$ICON_PATH" "$TITLE" "Added $URL to queue"
|
||||||
else
|
else
|
||||||
notify-send -i "$ICON_PATH" "Failed to add $URL to queue"
|
notify-send -i "$ICON_PATH" "$TITLE" "Failed to add $URL to queue"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user