Keyboard input redirection in X? - Printable Version +- nixers (https://nixers.net) +-- Forum: General (https://nixers.net/Forum-General) +--- Forum: Community & Forums Related Discussions (https://nixers.net/Forum-Community-Forums-Related-Discussions) +--- Thread: Keyboard input redirection in X? (/Thread-Keyboard-input-redirection-in-X) |
Keyboard input redirection in X? - dionys - 17-11-2020 *Which app will capture my input?* Various protocols are available under X to remap keys and alter response to key input (alt, ctrl, meta, et al.). Is there a clear way to understand what takes precedence, for instance, when you have (language dependent) alt-mapped keys, a window manager, terminal, and tmux that expect to use the same key-combinations to do different things? RE: Keyboard input redirection in X? - venam - 17-11-2020 I think one way to test this would be to set the same keybind on all levels and have something log when the event is captured, and then disable them when you find they were captured by one layer. I'll try to see if I'm able to test this, at least with the ones you mentioned: WM, tmux, terminal, command line tool, etc.. RE: Keyboard input redirection in X? - movq - 17-11-2020 As fas as I know, the basic and most common cases are something like this:
As for the pseudo terminal stuff, eduterm might be interesting. And then there is stuff like XInput2, which can just read everything, ignoring that hierarchy. Just run `xinput --test-xi2 --root`. There's also XRecord, IIRC. (Maybe that's implemented via XInput2 these days, no idea.) Lots of ways to write key loggers on X11. RE: Keyboard input redirection in X? - Dworin - 17-11-2020 This might be interesting: https://wiki.archlinux.org/index.php/Keyboard_input#Identifying_keycodes_in_Xorg but it kinda stops at the X11 level while 'our' problem occurs after that. Some info on the process can also be found here: https://gitlab.com/interception/linux/tools#where-does-libevdev-sit RE: Keyboard input redirection in X? - movq - 17-11-2020 Actually, could you clarify what you mean by this part? Quote:Various protocols are available under X to remap keys and alter response to key input (alt, ctrl, meta, et al.)Are you assuming that key events are filtered at runtime by the program that remaps them? I always thought that tools like xbindkeys change "the key map" and then quit. Like changing the keyboard layout from qwertz to qwerty. But I never had a deeper look at the details here. RE: Keyboard input redirection in X? - dionys - 18-11-2020 (17-11-2020, 04:31 PM)vain Wrote: Are you assuming that key events are filtered at runtime by the program that remaps them?I don't think so, at least not in most cases. But maybe it's better to be careful about what I mean by "mapping": 1). xkb mapping --> linking hardware keypress to keysymbol understood by X 2). application key mapping --> linking client functionality to specific key input In applications, (2) are sometimes hard-coded, or maybe they can be changed to correspond to something else in a config somewhere. Most programs probably don't mess with (1) for their own functionality. My mental model of the situation is that X has it's keyboard setup (via xkbmodel, xkblayout, xkbvariant, xkboptions) these determine which hardware keys correspond to specific input that X reads. From there, (I guess) lots of X protocols are available to pick up the mapped input. I assume most applications use this mapped input. Individual clients can take advantage of X protocols (directly or most likely through some library) to listen, intercept, maybe in rare cases block keyboard input. In my setup my keymap uses alt for accented letters ( żćęą ) so any application that expects e.g. alt-a, won't see it as the keyboard sends the code for "ą". Meanwhile, my WM responds to function keys via mapping that I have specified in my window manager config. I press F9, keycode 75 (keysym 0xffc6, F9) and my window manager creates and jumps to a new workspace. If I run MidnightCommander (which expects F9 to focus the menu) the mapped function keys do nothing in MC. RE: Keyboard input redirection in X? - dionys - 28-04-2021 Nice discussion of keyboard input here: https://unix.stackexchange.com/questions/116629/how-do-keyboard-input-and-text-output-work Good details and some history on Meta key input from Thomas Dickey: https://unix.stackexchange.com/questions/28993/what-is-bashs-meta-key RE: Keyboard input redirection in X? - dionys - 29-01-2022 So apparently the "Compose" key in xorg is ⇧ Shift + AltGr (while pressing AltGr before ⇧ Shift is the "fourth keyboard level modifier", a different key). Also: https://github.com/rrthomas/pointless-xcompose |