The valuable keyboard automation tool xdotool does not work on Wayland. A new tool that mimicks some of the functionality of xdotool, but that works both in Xorg and Wayland, is ydotool.

ydotool is available in the Ubuntu software center as version 0.1.8-3. It the mean time, the tool has been "refactored" in the sense that it has been completely rewritten, has no external dependencies and uses a lot less memory and without dynamic memory allocation. It is therefore strongly preferred to use a current version.

Only source code is provided on github, without instructions on how to build the code and install the tool. How can we install ydotool 1.0.1. on Ubuntu?


1 Answer 1


With the advent of Wayland, automation utilities like xdotool, which are designed for Xorg, do not anymore work. ydotool is a keyboard automation tool that works independent of the display manager, i.e., it works on both Wayland and Xorg.

Following are installation instructions I tested on Ubuntu 22.04. Credits to here for the compilation instructions using cmake.

1. Prerequisites

1.1 Make sure you have the necessary tools for compilation.

# Needed for compilation
sudo apt install cmake scdoc pkg-config

1.2 In Debian based distributions, checkinstall can be used to package the compiled code into a .deb file instead of moving the compiled files directly into the system directories. That way, the custom compiled program is known in the package management system, and can easily be removed again if desired.

# For generating an installable .deb file
sudo apt install checkinstall

1.3 Optional: Install git to clone from git. Alternatively, you can download and unpack the .zip file from the github page.

# Optional: git to clone the repository instead of downloading zip
sudo apt install git

2. Downloading and compiling

2.1 Download the source code using the git tool.

git clone  https://github.com/ReimuNotMoe/ydotool

Alternatively, download and unpack the zip file from the github page

2.2 Compilation

cd ydotool ## This will be `ydotool-master` if you extracted the zip file
mkdir build && cd build
cmake ..
make -j `nproc`

3. Installation

Instead of a classical sudo make install to install the compiled files into the system directories, checkinstall can be used on Debian based systems. checkinstall creates a .deb file which then can be installed using the APT package manager. Thus, the package management system knows about the package, and the package can easily be removed again using the package manager.

3.1 Start the tool

sudo checkinstall

3.2 Accept the default answer on the prompt

The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]:

3.3 Enter a description for the package

Please write a description for the package.
End your description with an empty line or EOF.

for example: Keyboard automation utility - custom install

3.4 Change the name of the package to something more meaningfull: on the prompt

This package will be built according to these values: 

enter 2 to change the package name to e.g. ydotool-custom. Thus, the package will be easily recognized later, and there will be no name conflict with the Ubuntu provided package.

3.5 Again accept the default answer, n, on the prompt

Some of the files created by the installation are inside the home directory: /home

You probably don't want them to be included in the package.
Do you want me to list them?  [n]: 

3.6 However, answer y on the next question

Should I exclude them from the package? (Saying yes is a good idea)  [n]: 

although answering no and leaving these files in probably does not hurt at all.

After this, the .deb is created and automatically installed. It could be reinstalled later with the command sudo apt install <path-to-debfile>.

4. Configuration

4.1 ydotool must run a root. There are probably more modern ways to allow a user to start the utility without using sudo, but the old trick is to set the suid bit on the executable.

# Set the suid bit so ydotool can be run by any user
sudo chmod +s $(which ydotool)

4.2 With the application, a systemd service is installed. Enable and install it:

# Have the the newly installed service recognized, enabled and started
sudo systemctl daemon-reload
sudo systemctl enable ydotool
sudo service ydotool start

4.3 The daemon expects the socket through which ydotool communicates on /tmp/.ydotool_socket. When run as user, ydotool looks for /run/user/<uid>/.ydotool_socket. One could make a symbolic link to /tmp/.ydotool_socket. Alternatively, you can set a variable YDOTOOL_SOCKET to indicate the socket to use.

  • Open ~/.profile in a text editor

  • Add the line

    export YDOTOOL_SOCKET=/tmp/.ydotool_socket

5. Test if it works

5.1 Log out then back in to have the environment variable take effect.

5.2 Open a terminal and test with following command:

ydotool type Ubuntu

The letters "Ubuntu" should be typed before your prompt reappears.

  • 1
    Thank you for a clear and comprehensive answer! With your instructions, the ydotoold service doesn't automatically start when the computer is restarted. To fix this, at step 4.2, after you have created the symbolic link, instead of reloading the daemon and starting the service, you need to enable the service and start it. This single command does the job: sudo systemctl enable --now ydotool. Thank you again. Oct 1, 2023 at 12:48
  • 1
    @PaddyLandau Thans for the feedback. I will update the instructions!
    – vanadium
    Oct 1, 2023 at 12:52
  • I had to manually create a link to get systemd to find the service... not sure why
    – Rick
    Oct 7, 2023 at 21:15
  • @Rick perhaps some "refresh" of systemd (e.g. by a system restart) is needed before a just installed service is recognized? I will check this out. -> Edit: I changed the order of the enable and reload commands: that should solve it
    – vanadium
    Oct 8, 2023 at 11:22
  • Edit /lib/systemd/system/ydotool.service and change the ExecStart= line to read ExecStart=/usr/bin/ydotoold --socket-own=XXX:YYY where XXX is the desired uid and YYY is the desired gid. If you're the only user on the system, then the id command tells you the uid and gid to use. Restart the ydotool service. Now ydotool works without root permissions.
    – djao
    Jan 30 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .