jordansissel / xdotool

fake keyboard/mouse input, window management, and more
Other
3.24k stars 318 forks source link

xdotool and xkb interaction #301

Open evalexpr opened 4 years ago

evalexpr commented 4 years ago

I have ctrl:swapcaps in my xkb options, and am trying to simulate pressing Ctrl+[.

I've tried this with xdotool key Caps_Lock+bracketleft as well as xdotool key Control_L+bracketleft. It works with both, however with either mapping, the Caps Lock mode of the device is activated, even when I'm using the Caps_Lock+bracketleft mapping (when I actually press this key combination on the keyboard, caps lock is not activated)

Is this a known limitation of the tool or a bug?

evalexpr commented 4 years ago

I've partially solved this by using --clearmodifiers but it's still a potentially unwanted interaction.

protist commented 1 year ago

@evalexpr I tested a few other options. ydotool also suffers from a related issue. For a swapcaps layout, you have to send a Caps Lock keycode, although ydotool doesn't activate Caps Lock itself. (This is not perfect for me. I have swapcaps on one keyboard and not another, so I don't want to hard-code the wrong key in.) I also had a look at uinputchars, but it looks like it also doesn't deal with keymaps.

In xdotool, --clearmodifiers looks like it does work, but I needed to insert a slight pause. e.g. for my script to type the current date.

sh -c 'xdotool type --clearmodifiers -- $(date +%y%m%d | tr "\\n" " ") ; sleep 0.1; xdotool key --clearmodifiers Shift_L'

so not ideal either.

EDIT

I also have shift:breaks_caps for my xkb, which might be necessary.