14

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.

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

  • It 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 Jan 28 '16 at 21:08
  • @Cestarian: You would have to create a fake input device with the kernel's uinput feature. – grawity Jan 29 '16 at 7:34
  • it 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 Jan 29 '16 at 7:50
  • 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 Feb 18 '18 at 9:38
0

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.

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.