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.


4 Answers 4


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.

  • 1
    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
    Jun 20, 2019 at 10:40
  • Note: this requires root! Aug 11, 2022 at 21:31

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.

  • This is cool, sadly it has the reverse issue of using xdotool on xwayland; the issue that it doesn't work with xwayland D:
    – Cestarian
    Jan 24, 2021 at 16:31
  • 1
    @Cestarian in what way doesn't it work for you with xwayland?
    – Maks
    Jan 24, 2021 at 21:03
  • 1
    it says so on the git page u linked to, at the bottom of the readme: To support arbitrary unicode characters, wtype generates a keymap on the fly and submits it to the compositor for distribution. Unfortunately this is broken under Xwayland as X has an upper limit on the amount of defined keycode-keysym pairs. Am I maybe misunderstanding something? it works on xwayland? (I can't really test it right now because I don't have a wayland compositor set up)
    – Cestarian
    Jan 27, 2021 at 23:12
  • I tried it under KDE neon Plasma Wayland session, but it didn't work, displaying this message: "Compositor does not support the virtual keyboard protocol"
    – Sadi
    Dec 25, 2021 at 18:05
  • I tried wtype and it seems like, disappointingly, that the protocol it relies on (virtual-keyboard-unstable-v1) is currently supported by neither Gnome nor KDE. (See here).
    – cyqsimon
    Aug 29, 2022 at 8:58

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

  • 1
    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, 2016 at 21:08
  • 1
    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, 2016 at 7:50
  • 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
    Feb 18, 2018 at 9:38
  • 1
    What's wrong with sending fake input? I understand the security issues with reading another programs input, but sending?
    – Lysol
    Jul 11, 2020 at 6:56
  • 2
    Thankfully the constant parroting of "security reasons" did not prevent the wayland developers from adding an appropriate protocol: gitlab.freedesktop.org/mstoeckl/waypipe/blob/v0.1.0/protocols/…
    – Maks
    Jan 24, 2021 at 6:34

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.