Wayland alternative for xorg's xdotool?

16

6

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

Posted 2016-01-27T23:12:37.127

Reputation: 1 418

Answers

3

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

user1686

Posted 2016-01-27T23:12:37.127

Reputation: 283 655

1It should be possible I think to create such a program that works for all wayland compositors. Libinput forwards user input to wayland, and it is through libinput that alt+f4 and other commands that use a wayland function can be triggered. All you have to do is trick libinput into reading a macro as a keyboard or mouse input; is what I think, but I have no idea how to do it myself. – Cestarian – 2016-01-28T21:08:54.970

@Cestarian: You would have to create a fake input device with the kernel's uinput feature. – user1686 – 2016-01-29T07:34:37.890

1it shouldn't be that difficult, I recall doing it in some driver work once, maybe if I just look at that code I could figure out some way. (Although I never knew what I was doing at the time) – Cestarian – 2016-01-29T07:50:17.317

1

There was a RFC on a mailing list: RFC: Interface for injection of input events and Add an API for taking screenshots and recording screencasts. It sounds like the challenges could be addressed with some additional security hardening work.

– Ben Creasy – 2018-02-18T09:38:49.343

3

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.

Satori Komeiji

Posted 2016-01-27T23:12:37.127

Reputation: 41

Sadly I couldn't make it run on Ubuntu 19.04. I installed libboost-program-options-dev, libevdevplus, libuinputplus and finally the ydotool itself, but I'm still getting ydotool: error while loading shared libraries: libboost_program_options.so.1.65.1: cannot open shared object file: No such file or directory

– m93a – 2019-06-20T10:40:19.513