L
L
lxyd2012-03-18 19:04:19
linux
lxyd, 2012-03-18 19:04:19

Keyboard event spoofing in Linux?

After several fruitless attempts, I will still write to Q&A.
BACKGROUND
I want to simplify my work with the keyboard under Linux (in Windows this is solved using AutoHotKey):
- CapsLock + HJKL - arrows (plus a couple more combinations);
- naked CapsLock - switching layouts;
- Shift + CapsLock - real caps.
First attempt: layout for xkb (Level3Switch is hung on the caps). Naked caps is generally impossible. Also, for some reason, nothing works in Java applications and some other programs (Monodevelop). In general, failure.
Second attempt: daemon robbing the caps and stinging the XTestFakeKeyEvent, releasing the keyboard for the duration of the event dispatch. Already better, but now it's buggy in the fox (from pressing CapsLock to releasing it, the focus is lost: the cursor is visible from time to time, the selection is not visible at all). In addition, it was not possible to get the auto-repit to work (and for arrows it is practically necessary).
ACTUALLY, THE QUESTION
I came to the conclusion that we need a daemon (maybe even a kernel module, I don't know), which will completely take /dev/input/event0 and give something else to the system. How to rob the device and read events, I found it here . It remains to figure out how to programmatically create a device that will be picked up by the system as a keyboard ?
I would be grateful for any links / advice on how to implement this idea.
I have never written systemic things, and I couldn’t dig it up on the Internet myself, sorry :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eddy_Em, 2012-03-18
@Eddy_Em

Maybe xdotool + xbindkeys will help you?

D
Denis, 2012-03-18
@uscr

As far as I know, all this can be solved by editing the X config.

D
darkdimius, 2012-03-18
@darkdimius

- naked CapsLock - switching layouts;
- Shift + CapsLock - real caps.
setxkbmap -layout "us,ru(winkeys)" -option "grp:caps_toggle,grp_led:caps"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question