Clicking/opening implicit hyperlinks doesn't work
tohn opened this issue · 7 comments
I'm using the latest version (xiate-git with some modifications), but I can't get it to work.
I've configured hyperlink_handler
to:
char *hyperlink_handler = "/path/to/bin/xiate_hyperlink.sh";
/path/to/bin/xiate_hyperlink.sh
contains:
#!/bin/bash if [[ ! -z "$BROWSER" ]] ; then "$BROWSER" --new-tab "$@" >/dev/null 2>&1 fi
$BROWSER
is in my case /usr/bin/vivaldi-snapshot
.
The only explanation I can find is: if I double click on a hyperlink, only the part after the protocol is selected (so for example //www.github.com/
).
Do you have any idea how to solve this?
Hmm, I can't spot any error at first glance. Let's see.
Let's make sure that there actually is an explicit hyperlink (none of the tools that I use print hyperlinks by default -- this feature is not adopted widely, it seems):
printf '\033]8;;https://github.com\aThis is a link\e]8;;\a\n'
There should be a dotted line below the text:
https://dump.uninformativ.de/v/Neids-Xubl-91/
Move the mouse over that text and press the right mouse button (once). This should activate your handler. If this still doesn't open the link in your browser, please try the following simple handler:
https://github.com/vain/bin-pub/blob/master/xiate-hyperlink-handler
Is /tmp/xiate-hyperlinks
being created? What's its content?
Aha, thanks, then I didn't grasp the difference between explicit and implicit hyperlinks, my bad.
Printf + your script works, so I have no problems with explicit hyperlinks. But since they're rare, I'm more interested in implicit hyperlinks which still don't work.
Is the handler even there for implicit hyperlinks? Or is there another thing I didn't see?
If I click on a hyperlink (right mouse button, once) it's copied to CLIPBOARD
though.
Oh, yeah, that's misleading.
No, there is no handler for regular URL matches. They are always copied to CLIPBOARD
.
Maybe there should be such a handler. And maybe the variables in config.h
should be renamed. It's not entirely clear what url_regex
and hyperlink_handler
mean. :/
I'll have a look at this in the next few days.
Okay, I've pushed some changes to master
, that you might want to check. Both types of links (those matched by regexes and explicit hyperlinks) will now be fed to a user defined handler.
Please have a look at CHANGES
, the manpage and probably also the comments in config.def.h
. It's not particularly difficult to understand what's going on :), but things work a bit differently now.
Awesome, thanks a lot! I can now open both hyperlink types with the same script, nice :)
Btw, is there a reason why opening links happens with the right mouse button? If not, maybe another idea would be to use the left one to open links (implicit and explicit ones) and with the right one one could save the link to the clipboard. I'm now using xclip like suggested since I came to like the idea of having the link also in my clipboard after clicking on it.
Btw, is there a reason why opening links happens with the right mouse button?
Yeah, the left button is used for regular text selection and I wanted to keep that option even when hovering over links. For example, I sometimes want to copy only the hostname of a URL, or something like that. The middle mouse button is always used for pasting text from PRIMARY
. This leaves us with the right mouse button as the only button to be used for "special" actions, like calling the handlers.
I could introduce a context menu that opens on the right mouse button. This is what sakura does. I don't know, that's quite a lot of code and I doubt that I would make actual use of it. Plus, in theory, one could launch something like dmenu from link_handler
and implement a freely programmable "context menu" that way.
I think I'll keep using the current version for a while and see if anything is bugging me. :)
Yeah, makes sense. Before in urxvt + matcher perl extension I pressed Shift
and selected the URL either by double clicking on the part I wanted to copy or just selecting it by marking it.
This is different now in xiate, so I can understand your choice. Since I'm now fine with it and the dmenu idea is also a nice way of doing it, I'll close this issue now :)
Thanks again for the changes!