Just wondering since I know a lot of people quietly use a screen-area-select -> tesseract OCR -> clipboard shortcut.
- I separate subjects of interest into different Firefox windows, in different workspaces – so I have an extension title them and a startup script parse text to ask the compositor to put them in the correct workspace (lets me restart more conveniently).
- I have automatically-set different-orientation wallpapers for using my 2-in-1 depending on whether I use it in portrait or landscape (kind of just for looks, but I don’t think if anyone else adds a wallpaper change to their screen rotation keybind).
While I doubt the concept is unique, the script is: a keyboard shortcut will check the clipboard for a YouTube link and then show launcher options for
mpv
oryt-dlp
, including launch arguments for lower quality format and audio only. It launches that in a terminal for easier handling when yt-dlp doesn’t work properly (much more common if using proxies, but also if a video is age-restricted or deleted).So when I see a yt link here, I can just copy it, keyboard shortcut and then it’s playing in my local video player.
edit: here’s the script. It assumes
xsel
(clipboard access),rofi
(menu creator),gnome-terminal
(terminal) andnotify-send
(system notification on failure) are installed and working, you’ll need to replace any which don’t match your system. My DE just runs it in bash when the shortcut is entered.Code (click to expand)
#!/bin/bash ARR=() ARR+=("mpv full") ARR+=("mpv medium") ARR+=("yt-dlp") NORMAL_URL=`xsel -ob | sed -r "s/.*(v=|\/)([a-zA-Z0-9_-]{11}).*/https:\/\/youtube.com\/watch?v=\2/"` CHOICE=$(printf '%s\n' "${ARR[@]}" | rofi -dmenu -p "mpv + yt-dlp from clipboard") DOWNLOAD="false" MPV="false" OPTIONS="" if [ "$CHOICE" = "mpv full" ]; then MPV="true" fi if [ "$CHOICE" = "mpv medium" ]; then MPV="true" OPTIONS+="'--ytdl-format=bv*[height<721]+ba' " fi if [ "$CHOICE" = "yt-dlp" ]; then DOWNLOAD="true" fi if [ $MPV == "true" ]; then COMMAND="mpv $OPTIONS $NORMAL_URL" gnome-terminal --title "$NORMAL_URL" -- bash -c "echo $COMMAND;$COMMAND;if [ \$? -ne 0 ]; then notify-send 'yt-dlp failed' $NORMAL_URL; bash; fi;" elif [ $DOWNLOAD == "true" ]; then COMMAND="yt-dlp $OPTIONS $NORMAL_URL" gnome-terminal --title "$NORMAL_URL" -- bash -c "echo $COMMAND;$COMMAND;if [ \$? -ne 0 ]; then notify-send 'yt-dlp failed' $NORMAL_URL; bash; fi;" fi
Uh this sounds awesome, care to share?
Uh I would be interested in that actually! Nowadays Youtube generates lots of problems with freetube due to their cookie bullshit and I feel with mpv(yt-dlp) in cli I at least have the option to see whats going on.
Same