improved mpv scirpt

This commit is contained in:
joy 2024-10-09 16:45:33 +02:00
parent 20110a0d5c
commit 74bf73c7ec

View file

@ -1,11 +1,21 @@
#!/bin/sh
# Get the URL from the clipboard
link=$(wl-paste)
# Check if the link is not empty
if [ -n "$link" ]; then
mpv "$link" &
# Notify the user that the link is about to be opened
notify-send "Opening Link" "$link"
notify-send "Opening Link" "$link" --icon=video-x-generic
# Try to open the link with mpv and capture any errors
error_message=$(mpv "$link" 2>&1)
if [ $? -ne 0 ]; then
# If mpv fails, notify the user with the error message
notify-send "Error" "Failed to open the link with mpv:\n$error_message"
fi
else
notify-send "Error" "No URL provided." --icon=dialog-error
notify-send "Error" "No URL provided."
fi
i