ARTICLE AD BOX
I am attempting to simulate keyboard input on Wayland with Gnome.
Consider the following Python script:
from evdev import UInput, ecodes as e ui = UInput() ui.write(e.EV_KEY, e.KEY_A, 1) ui.write(e.EV_KEY, e.KEY_A, 0) ui.syn() ui.close() When I run this without sudo, it gives a permission error (that is expected). When I run this with sudo, it prints nothing.A small modification of this script causes it to print a as expected:
from evdev import UInput, ecodes as e import time ui = UInput() time.sleep(5) ui.write(e.EV_KEY, e.KEY_A, 1) ui.write(e.EV_KEY, e.KEY_A, 0) ui.syn() ui.close()Unfortunately, this requires injecting a fixed five-second delay, which is not ideal, and likely not robust on different systems.
Is there a direct way to have the script block until UInput is ready?
I looked at the docs but did not find anything obvious.
