Best way to send an arbitrary sequence of key presses to an X window? #190
Replies: 2 comments 2 replies
-
|
I am going to answer my own question, but if anyone has a nicer way, I am all ears. The following essentially accomplishes arbitrary string insertion into X windows: (defun exwm-send-string (str)
"Takes a string and sends it (character by character) to the currently selected window if it is an X window."
(if exwm-window-type
(mapcar (lambda (char)
(exwm-input--fake-key (aref (read-kbd-macro (string char)) 0)))
str
)))This is obviously horribly unsafe if you are not currently focusing some kind of text input. Just imagine the havoc this could wreak if you for some reason happen to have a graphical vim instance open in normal mode. But I do not believe it is possible to reliably figure out whether an X application currently thinks it has a text input, so this is probably best possible. |
Beta Was this translation helpful? Give feedback.
-
|
Maybe you can use an input method. See sinic/autocharmode#1 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes I would like to insert text into an input field in an X application, which is of course not possible (okay, there is a shared clipboard, but that is not sufficient). However, if I could send raw key presses to the currently selected window, I could essentially make LISP type out my text for me. Clearly sending key presses to windows is possible (both
exwm-input-send-next-keyand simulation keys exist), so is there a way to tell EXWM to just take a sequence (a string) and send them in quick succession?Obviously I could programmatically define simulation keys to do this, but if I want to be able to insert arbitrary strings, that would very quickly fill up the available disk space in the universe.
Edit: Github does not like org formatting.
Beta Was this translation helpful? Give feedback.
All reactions