11

Is there a way to make xdotool or xte or any other alternative to work in Fedora 26? I'm trying to emulate keypresses (using xbindkeys), e.g. pressing Alt+B would emulate pressing Ctrl+Shift+B. But apparently neither xdotool nor xte work in Wayland (for security reasons [?])

Is there a workaround? Otherwise how do I rebind keys to other keys?

1

2 Answers 2

12

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

1
  • Finally got the nice project working on Fedora/Wayland/GNOME after probably xte was not helping with xbindkeys or isolated, and maybe a small attempt with evemu-event. After pip and about 4 systemtl commands, I also needed this command after some GUI configuration: sudo key-mapper-control --command start --device "<keyboard>" --preset "<preset>"
    – Pysis
    Dec 14, 2021 at 22:14
7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.