Keyboard emulation in Wayland
Solution 1
I'm using this little script. It needs the package evemu installed and sudo-confguration for evemu-event without password-notification. EVDEVICE
is the device used to emulate the input. /dev/input/event8
is my keyboard (use sudo evemu-record
to find yours)
#!/bin/bash
# keycomb.sh
EVDEVICE=/dev/input/event8
for key in $@; do
sudo evemu-event $EVDEVICE --type EV_KEY --code KEY_$key --value 1 --sync
done
# reverse order
for (( idx=${#@}; idx>0; idx-- )); do
sudo evemu-event $EVDEVICE --type EV_KEY --code KEY_${!idx} --value 0 --sync
done
you can e.g. change a tab with ./keycomb.sh RIGHTCTL PAGEDOWN
.
Please note: This script does no validation on parameters, use with care ;)
EDIT Feb 2021: Finally I found a project doing it right: https://github.com/sezanzeb/key-mapper
Solution 2
This is too long for a comment, but not really an answer... I recently came across some python code which says
Simple script to replace xdotool when using Gnome/Wayland for entering keystrokes using evdev.
which could be a starting point. I have not tried it. It needs the python package evdev, and has to run as user root.
There is also an evemu package which says
evemu records and replays device descriptions and events, making it possible to emulate input devices through the kernel's input system. Emulated devices are for most practical purposes indistinguishable from real devices.
Related videos on Youtube
Comments
-
iLemming almost 2 years
Is there a way to make
xdotool
orxte
or any other alternative to work in Fedora 26? I'm trying to emulate keypresses (using xbindkeys), e.g. pressingAlt+B
would emulate pressingCtrl+Shift+B
. But apparently neitherxdotool
norxte
work in Wayland (for security reasons [?])Is there a workaround? Otherwise how do I rebind keys to other keys?
-
Ben Creasy over 6 years
-
-
Pysis over 2 yearsFinally got the nice project working on Fedora/Wayland/GNOME after probably
xte
was not helping withxbindkeys
or isolated, and maybe a small attempt withevemu-event
. Afterpip
and about 4systemtl
commands, I also needed this command after some GUI configuration:sudo key-mapper-control --command start --device "<keyboard>" --preset "<preset>"