links2  mpv  ratpoison  tutorial 

2023-08-25

Video of a man killing rats

How I watch y*utube in ratpoison.

I'll explain using the default ratpoison keybindings and links2 in graphical mode. This could be easily adapted to things like dmenu, cwm, probably to any window manager that has a scriptable launcher.

What you need:

(!ba)shing rocks

Start by making a custom script, change BROWSER and INVIDIOUS_INSTANCE accordingly. For example you could start links in a terminal ala BROWSER="xterm -e links".

#!/bin/sh

BROWSER="links -g"
INVIDIOUS_INSTANCE="https://yewtu.be"

if [ -z "$1" ]; then
    $BROWSER "$INVIDIOUS_INSTANCE";
        else
    $BROWSER "$INVIDIOUS_INSTANCE/search?q=$*";
fi

If the script is executed without any arguments, a browser is opened on the landing page of your selected invidious instance. If the script is executed with a however many arguments, all the arguments will be parsed as a search query.

Don't forget to make the script executable.

 $ chmod u+x the_script.sh

ratpoisonrc

Add this line to your ~/.ratpoisonrc file. We're declaring that running 'vid' inside ratpoison's prompt will execute the previous script.

alias vid exec /path/to/the/previous/the_script.sh $*

You can test it by entering the previous line in ratpoison's prompt, ala

  C-t : alias vid exec /path/to/the/previous/the_script.sh $*

but this will not persist between restarts. Let's suggest the line was placed in the configuration file.

  C-t : restart (this restarts ratpoison and loads the new configuration)

grabbing a URL of a video

By now, if you do

  C-t : vid some video

Links2 will open and a search will be made. I like to use the graphical mode for this part, because it makes it stupid simple to get the URL.

Select the video and either press the 'Menu' key on your keyboard, the thing between AltGr and Ctrl, select 'Copy link location', or open the page with the video, press Shift-G, this opens the url bar with the current page, Control-U, this cuts the url into buffer.

Whichever method, the url of the video is now copied.

playing the video

  C-t ! mpv C-y (this pastes the url into ratpoison's prompt)

For clarity. C-t ! opens ratpoison's shell prompt. Type 'mpv', then press Control-Y, hit enter. mpv will begin playing the video in the current frame.

Done. Never visit youtube again. Never use firechromecryptobrowser.

run links.

bonus

Rip audio from the video and download it.

 $ yt-dlp -x $URL 

resources

This post is not sponsored by the #links2gang, but it should be.