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: an Action for sending arbitrary messages to TCP Client #854

Closed
wis opened this issue Mar 19, 2024 · 0 comments · Fixed by #855
Closed

Feature request: an Action for sending arbitrary messages to TCP Client #854

wis opened this issue Mar 19, 2024 · 0 comments · Fixed by #855
Labels
enhancement New feature or request

Comments

@wis
Copy link
Contributor

wis commented Mar 19, 2024

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

Since the day I started using Kanata I wanted a way to do this, that is besides using cmd, cmd comes with a big security risk, especially if you run Kanata as Admin or superuser/root, and cmd is too slow on Windows, due to the higher executable startup time on Windows, ~10X slower than on Linux, on Windows it takes 100ms for a "Hello World" C program to run, on Linux it takes less than 10 milliseconds or even less than 5ms. a TCP message to a local TCP client takes less than 1 millisecond (microseconds).

Latency is really important if you want to run code on each key press/release/tap, or when performing any keyboard behavior that can be modeled/configured in Kanata, e.g. a chord. (feels/seems related to #797 )

Describe the solution you'd like.

I would like to use TCP as an IPC mechanism, also to replace the use of cmd, I no longer want to use Kanata compiled with the cmd feature flag.

Action naming suggestion: push-msg
usage example:

(defsrc a s d)
(deflayer a 
(push-msg hello "how are you")
(push-msg $what (arbitrary S (expression (that can nest) here) )
)
(defvar
what any
)

TCP server message JSON schema:

{ "MessagePush": { "message": ["an", "(arbitrarily nested)", "array", "not", "a", "string"] } }

the server message for the above examples would be:

{ "MessagePush": { "message": ["hello", "how are you"] } }

and

{ "MessagePush": { "message": ["any", ["arbitrary", "S", ["expression", ["that", "can", "nest"], "here" ] ] ] } }
formatted with Prettier
{
  "MessagePush": {
    "message": [
      "any",
      ["arbitrary", "S", ["expression", ["that", "can", "nest"], "here"]]
    ]
  }
}

Describe alternatives you've considered.

None that I could find.

Additional context

This is related to #496, this action/feature enables you to send events on any key down and up using fake keys, explicitly. this is my top use case out of this feature as of now, but I can see many scenarios/cases where this feature/action would be needed too.

@wis wis added the enhancement New feature or request label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant