44

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.

Cestarian
  • 1,997

5 Answers5

14

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.

10

There's 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.

Giacomo1968
  • 58,727
Maks
  • 201
6

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).

grawity
  • 501,077
2

There's dotool

Like ydotool it uses uinput so it's linux specific but independent of X11/Wayland, and even works in TTYs.

I wrote dotool because ydotool was only designed to run as root and requires a daemon.

geb
  • 21
1

I've just spent a couple of hours installing KDE 6 on Arch and installing dotool plus a new one, kdotool.

Between dotool for output and kdotool which uses kwin's scripting and dbus interfaces I can once again do the things I currently do with xdotool and devilspie2 on xfce. Check the windows names to filter actions in response to hotkeys, locate the mouse and move things where I want them and output clicks or text to the desired window.

I still have a major task after KDE 6 and Wayland are a little more stable and widely supported but I can now see a post X11 future that I'm happy with.

John 9631
  • 159