jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
1.39k stars 99 forks source link

Feature request: action accepting an arbitrary string handled by user-written code #797

Open jtroo opened 4 months ago

jtroo commented 4 months ago

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

Have a mechanism for people willing to write Rust code to easily add their own desired behaviours without needing to know too much about the keyberon library or the kanata processing loop.

Describe the solution you'd like.

Add a new list action (custom-behaviour "whatever string you want").

https://github.com/jtroo/kanata/blob/634ed973ce9aa2a6e22aa162efad0e1a493e985b/parser/src/cfg/mod.rs#L1271

Add a new custom action CustomBehaviour(String)

https://github.com/jtroo/kanata/blob/634ed973ce9aa2a6e22aa162efad0e1a493e985b/parser/src/custom_action.rs#L12

Add handling for press and release of CustomBehaviour. Define easy-to-find functions that accept the string defined in CustomBehaviour, which would be where users can add their code. Probably makes sense to put in a new file. Custom behaviour will be stringly typed 🧵.

https://github.com/jtroo/kanata/blob/634ed973ce9aa2a6e22aa162efad0e1a493e985b/src/kanata/mod.rs#L918-L918

Add some documentation for how to interact with OS and read layout state.

Describe alternatives you've considered.

A user could certainly write their own code using llhook/evdev to do custom behaviours. But since kanata already has a lot of nice built-in behaviours that work mostly-fine out of the box, it might be nice to fork and extend kanata and add that little bit extra that's missing.

Though perhaps cmd is already a sufficient mechanism for this... ?

Additional context

N/A

jtroo commented 4 months ago

This wouldn't be all that hard to implement, but I wonder if anyone would use it 😅

jtroo commented 3 months ago

This is an interesting potential integration too: https://github.com/mattwparas/steel

eugenesvk commented 3 months ago

By the way, what about making these shareable/plugin-like so you could use someone else's custom action?

Alternatively, is something less obscure than steel and more polyglot like, e.g., some kind of wasm custom action runtime feasible for an app like kanata?

Also

Though perhaps cmd is already a sufficient mechanism for this... ?

cmd flashes console windows when used with simple scripting commands with a gui app, which is rather disruptive