134
submitted 2 days ago by fool@discuss.tchncs.de to c/linux@lemmy.ml

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).
you are viewing a single comment's thread
view the rest of the comments
[-] comfy@lemmy.ml 10 points 1 day ago* (last edited 58 minutes ago)

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 or yt-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) and notify-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

[-] prole@lemmy.blahaj.zone 2 points 8 hours ago

Uh this sounds awesome, care to share?

[-] comfy@lemmy.ml 1 points 1 hour ago

Now added to my comment :)

[-] dino@discuss.tchncs.de 6 points 13 hours ago

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.

[-] comfy@lemmy.ml 1 points 1 hour ago

Now added to my comment :)

[-] jherazob@beehaw.org 1 points 9 hours ago
[-] comfy@lemmy.ml 1 points 1 hour ago

Now added to my comment :)

this post was submitted on 14 Jan 2025
134 points (99.3% liked)

Linux

49035 readers
707 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS