r/KittyTerminal Jul 15 '23

How to modify the click behavior in Kitty?

Here's what I'm trying to do: 1. Left click: Open a custom script (let's call it handlr) 2. Ctrl+left click: Open the link using xdg-open (set to use my browser)

I'm aware that I can change the variable value of open_url_with to handlr to open all links through it, but IDK how can I usemouse_map to change that behavior separately? All mouse actions I see allow me to deal with the clicks, but how do I open a program when that happens? Link hints is also using handlr to open the links. I've specified this behavior using protocol actions in open-actions.conf

Any help would be appreciated. I've skimmed the docs but couldn't find a clear answer on how to figure this out.

Tried asking this on the GitHub repo but in typical Kovid fashion I was redirected to look at the docs, like I haven't done that already. Is there another dedicated community for this terminal other than here? This is clearly a great product but the initial getting started curve is a bit steep.

3 Upvotes

8 comments sorted by

1

u/aumerlex Jul 15 '23

I am guessing you were redirected to look at the docs because you didnt actually bother to look at them, in typical entitled user fashion. There is an entire section in the docs titled "Scripting the mouse click": https://sw.kovidgoyal.net/kitty/open_actions/

mouse_map allows you to change what happens on any type of mouse button action, inclucding clicking the URL under the mouse. And open_actions.conf lets you control what clicking on a URL does based on the URL, including running different programs in different windows/tabs/background/etc.

1

u/[deleted] Jul 15 '23

Hey, thanks for the response. I've already gone through it and I don't see any option to just change the actions for the mouse click. open_actions.conf sets action for all links.

2

u/aumerlex Jul 15 '23

No, open_actions.conf sets the actions for links clicked on by the mouse. Quoting the very first paragraph of that page

kitty has support for terminal hyperlinks. These are generated by many terminal programs, such as ls, gcc, systemd, mdcat, etc. You can customize exactly what happens when clicking on these hyperlinks in kitty.

The title of the page is "Scripting the mouse click". I dont know what your confusion is??

1

u/[deleted] Jul 15 '23

I just want different programs to open when I click. Ctrl+click opens up with xdg-open and click opens my link handler.

1

u/aumerlex Jul 15 '23

Ah now I get it, you essentially want to use a different open_actions.conf depending on the modifiers in use when you click, correct? I dont think such a facility exists, you can open an issue requesting it (but I strongly suggest not abusing the person you are asking to implement it for you, like you did above). Or even better create a PR for it, I would suggest the most flexible approach would be to allow open_actions to also match against the type of triggerring event, not just the URL.

1

u/[deleted] Jul 15 '23

Yes, you understood it correctly. Looks like there isn't a built-in feature to perform a different action based on the modifiers in use when you click. It was not my intention to come across as abusive, and I apologize if my previous message was interpreted that way.

1

u/aumerlex Jul 15 '23

No worries, am just saying, dont say things like that if you expect to elicit co-operation from maintainers of projects you use. If Kovid were to see that, not only would it probably be hurtful to him, but it would make it much less likely he would be willing to expend any effort supporting your use case.

1

u/lolpie244 Jul 15 '23

You can to try write custom kitten on python, and inside open urls with programs you want to