The first thing I missed when I started using Elinks was the possibility to copy both the current address and link addresses directly into the clipboard (like Vimperator’s “yank” command does, for instance).
Then Google told me Elinks had a function called URI passing, that is the possibility to pass a URL to an external command. No need to tell this is a blessing.
Preliminary Operations
Before we start: Remember that in order to copy URLs into the clipboard you will need to install the program xclip if it’s not already installed on your system.
The first thing to do is defining keyboard shortcuts to activate the URI passing command. Pressing k and then t (Toggle Display) gives us a non-descriptive view of all bindable commands. What we need to find is the command called link-external-command and his close relative tab-external-command (press s to search). The former one activates a command on the selected link, and the latter on the current URL. All we need to do at this point is setting up those commands. But first let us define our keyboard shortcuts: select both items (one a time, of course) and press a (Add). If you don’t feel so imaginative right now, you might like to know that I have used ALT+o and ALT+p as shortcuts.
Copying the URL in the clipboard
In order to activate this command you need to access the Document menu. To do so, just press o to open the Options window, and expand Document by selecting it and pressing +. Find the subsection called URI passing and select Add. Enter the name of your new command (I called it “clip”). Now select Edit and write the actual command:
echo -n %c | xclip -i
Save and close.
Watching Youtube videos
Before you even look at this remember that you will need the script youtube-dl in order to use this feature.
The first thing to do is creating a little script that does the job: streamining Youtube videos in Mplayer. Here’s how you do it:
#!/bin/bash
video_url=`youtube-dl -g $1`
mplayer -vc ffflv -ac mp3 -cache 300 -prefer-ipv4 $video_url > /dev/null 2>&1
As you probably already know, you need to save the code above into a text file, make it executable and possibly put it into your executables path.
Getting back to Elinks, using this script with it is very easy at this stage: just create a new command in the URI passing submenu. When you select Edit this time, just enter the name of the script above followed by “%c”. In my case I have called it “ut”:
ut %c
Save and close.
Conclusion
Now when we have a link highlighted all we need to do is pressing for example ALT+p in order to pass it to either of our scripts. Same goes for the current page’s URL, except that we press ALT+o. You will see a little menu with the name of our commands (”clip” and “youtube” in my case). Select one and enjoy.
References
[...] Youtube and other such sites. I will describe two ways here, one using youtube-dl (wholly following finferlu’s explanations) and the other clive (or cclive if you prefer that). Both methods use mplayer to play the video, [...]
Posted by Watching Youtube videos in Elinks « urukrama’s weblog on January 3rd, 2010.