Wayland alternative for xorg's xdotool?

xdotool is a nice X application, I tend to use it for creating macro commands (like alt+f4 or ctrl+w or ctrl+alt+backspace or something like that)

It's really easy to use and convenient, but I don't know of any wayland compatible program like this. is there any way to send mouse and keyboard input signals to wayland right now similar to xdotool for X?

It works largely with xwayland right now, but not all commands work (such as alt+f4, xev can even read the alt+f4 input but it doesn't trigger the application termination like pressing it on the keyboard) there's also the matter of potentially not using xwayland.


Solution 1:

There's currently no perfect solution, but there's a close one: ydotool.

It uses the uinput interface as backend, and has no dependency on display servers.

Solution 2:

No, such features were explicitly excluded from the Wayland design for security reasons. (Reading other programs' input is the biggest problem, but allowing fake input to be sent to other programs can also lead to troubles.)

That said, I do expect some Wayland WMs to eventually implement some sort of macros feature; after all, they will need to support on-screen keyboards and voice control (for accessibility).

But if such a feature existed, it would depend on which Wayland compositor you're using: Weston? KDE's KWin? GNOME Shell? Enlightenment? There is no "display server – window manager" split in Wayland; the window manager is the Wayland server and decides which features to implement (either as Wayland sub-protocols or as D-Bus APIs or such).

Solution 3:

Therer is now another option for xdotool like functioality on Wayland, the wtype tool.

More details on the Wayland protocol used by wtype can be found in this blog post.