Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: (un)install keyboard hook on (tcp?) demand #860

Open
eugenesvk opened this issue Mar 20, 2024 · 3 comments
Open

Feature request: (un)install keyboard hook on (tcp?) demand #860

eugenesvk opened this issue Mar 20, 2024 · 3 comments
Labels
enhancement New feature or request llhook Pertains to the standard version of Kanata on Windows PRs welcome jtroo has no plans to work on this at present, but PRs are welcome windows Issue pertains to Windows only

Comments

@eugenesvk
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Currently the order of keyboard hooks installed by various apps can't be predetermined. This introduces hard-to-avoid conflicts, making it hard to use, for example, AutoHotkey and kanata side-by-side.

Describe the solution you'd like.

aunch kanata in a "waiting-to-start-a-hook" mode, where it sets up all the processing machinery, but doesn't actually install the keyboard hook.

Then on some external activation even, for example, a message sent via TCP: 1) "activate layer_with_kbd_hook_F", 2) "F is down" 3) "exit on F up" kanata would:

  • install the keyboard hook and launch the input event loop
  • switch to the layer_with_kbd_hook_F layer
  • force-feed that f key down event to the loop so that kanata's state machine is aware of it
  • process all events from the hook as usual until the exit event ("F up" in this example)
  • uninstall keyboard hook

Given that the latest installed keyboard hook has priority, this should be more reliable for that timing the launches of various apps since those apps can also (un)install hooks dynamically

Describe alternatives you've considered.

My other idea was to maybe use kanata as a lib when it supports #816

Additional context

No response

@eugenesvk eugenesvk added the enhancement New feature or request label Mar 20, 2024
@rszyma
Copy link
Contributor

rszyma commented Mar 20, 2024

Why not just write a script that manages the order of launching each of keyboard remapping program you have? You could add a logic to kill and re-start entire remapping chain if one the programs get killed, if that's an issue in the first place.

@eugenesvk
Copy link
Contributor Author

because even if I start the programs in the correct order (and nothing gets killed), I still get weird resets in priorities where kanata stops working on keybinding conflicts

Also (maybe) because remapping program can launch hooks dynamically in response to keyboard events, though that shouldn't (in theory) be an issue since these dynamic hooks upon disappearing should preserve the order of the original 2 hooks?

I'm hoping that if kanata installs its hook dynamically there will be no way for anything else to interfere

@jtroo jtroo added windows Issue pertains to Windows only PRs welcome jtroo has no plans to work on this at present, but PRs are welcome llhook Pertains to the standard version of Kanata on Windows labels Mar 21, 2024
@eugenesvk
Copy link
Contributor Author

By the way, do you know whether it's possible to list all keyboard hooks and see their "priorities"? Maybe this could help debug the issue of conflicts between two apps (from some searching and SO answers it seems there is no API for that, but maybe?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request llhook Pertains to the standard version of Kanata on Windows PRs welcome jtroo has no plans to work on this at present, but PRs are welcome windows Issue pertains to Windows only
Projects
None yet
Development

No branches or pull requests

3 participants