#!/usr/bin/env bash # Copyright 2021, P. Lutus # Released under the GPL # user's preferred terminal terminal=gnome-terminal # relaunch in a terminal window tty -s || exec $terminal -- $0 "$@" # set "pr=n" to limit video resolution # to avoid YouTube stalling the download # example settings 1080, 720, 576, 360, 240 # set to "-1" to specify best available resolution # but this setting may create stalls during video playback pr=576 echo "VLC clipboard launcher ($pr): keep this window open." echo "To use, copy a video URL to the clipboard." echo "To exit, close this window." xclip -i <<<"" # clear prior clipboard content while true; do newurl="$(xclip -o)" # get clipboard contents # only if clipboard contains recognizable URL if [[ $newurl =~ https?:// ]]; then echo -en "\r\033[KPlaying: $newurl ... " # erase clipboard xclip -i <<<"" # close prior VLC player(s) killall vlc 2>/dev/null # launch VLC and suppress error/activity log # -f means launch full-screen # vlc://quit means close when video is done { vlc --preferred-resolution $pr -f "$newurl" vlc://quit 2>&1 > /dev/null; } 2>&1 > /dev/null & fi sleep 1 done reply -p "Press Enter to close this window:"