Add a new command and keymap in Hints mode

76 views
Skip to first unread message

Karthik K

unread,
Apr 11, 2015, 9:23:46 AM4/11/15
to penta...@googlegroups.com
I'm looking for a way to open video urls in my video player (mpv) from within pentadactyl. A rough idea to go about this, would be to have a key mapped in Hints mode to a function or command that will take the selected link as argument. The function or command can then call mpv with the link.

Say, the key I want to map is "m", then pressing ";m" should open Hints mode and allow me to choose a link, then automatially mpv should be opened playing that link. Any ideas on how to go about this?

Lit Wakefield

unread,
Apr 11, 2015, 12:20:53 PM4/11/15
to penta...@googlegroups.com
I don't think this would make sense as a hint since most often on a tab there is only one video playing.

For websites that youtube-dl supports (assuming you have the latest mpv), you can just add a mapping like this:
nmap -ex <leader>y execute "silent !mpv '" + buffer.URL + "' &"

For other websites, I've been using a script that fakes clicks and mouse movement to open firebug, click on a video to pause/play it, copy the direct link, and then pass that url to mpv. This is pretty hideous, but it works on 99% of sites I've tried. I just found the media sniffer plugin which would be easier to use since it automatically puts the direct link in the right click menu. So that's one way to do it. Do you have any js experience? It would be much nicer to get the direct link with js from firebug or media sniffer or some other way and just make a command instead of faking mouse movement. I'll see if I can figure out a way to do that..

wsha...@gmail.com

unread,
Apr 12, 2015, 9:27:56 PM4/12/15
to penta...@googlegroups.com
Lit's recommendation might be appropriate in this case, but here's an example of how to add a hint with JavaScript:

hints.addMode('d','Echo destination of element',function(elem) dactyl.echo(elem.href));

Like in Lit's example, you could use commands.execute("!mpv " + elem.href + " &") for the hint function.
Reply all
Reply to author
Forward
0 new messages