-
-
Save azend/c5841c01067d59e2220a to your computer and use it in GitHub Desktop.
Script to monitor clipboard for a new Youtube URL and plays the video when the URL does not match the existing URL. Also does not run when an mpv instance is already running.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function loop(){ | |
sleep 2 | |
url=`xclip -selection clipboard -o` | |
if [[ `cat /tmp/youtubeurl` == "$url" ]] | |
then | |
return | |
fi | |
mpv=`pgrep mpv` | |
if [[ $url == *"youtube"* && $mpv == "" ]] | |
then | |
echo "$url" > /tmp/youtubeurl | |
mpv --hwdec vaapi --ytdl-format=bestvideo[ext=mp4]+bestaudio[ext=m4a] "$url" | |
fi | |
} | |
while(true) | |
do | |
loop | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment