jinliu / kdotool

xdotool-like for KDE Wayland
Apache License 2.0
113 stars 8 forks source link

kdotool - a xdotool clone for KDE Wayland

Introduction

Wayland, for security concerns, removed most of the X11 APIs that xdotool uses to simulate user input and control windows. ydotool solves the input part by talking directly to the kernel input device. However, for the window control part, you have to use each Wayland compositor's own APIs.

This program uses KWin's scripting API to control windows. In each invocation, it generates a KWin script on-the-fly, loads it into KWin, runs it, and then deletes it, using KWin's DBus interface.

This program should work with both KDE 5 and the upcoming KDE 6. It should work with both Wayland and X11 sessions. (But you can use the original xdotool in X11, anyway. So this is mainly for Wayland.)

Not all xdotool commands are supported. Some are not available through the KWin API. Some might be not even possible in Wayland. See below for details.

Please note that the window id this program uses is KWin's internal window id, which looks like a UUID ({xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}). It's not a X11 window id.

Global Options

Options not in xdotool:

New Commands Not In xdotool

The following can be used in chained commands:

Supported xdotool Commands

Window Queries

These commands generate a window stack that following window action commands can refer to.

Window Actions

These commands either take a window-id argument, or use the window stack.

Global Actions

These actions aren't targeting a specific window, but the whole desktop.

Won't support

You can use ydotool, dotool, wtype, etc. for these:

KWin doesn't have such functionality:

X11-specific:

Unclear if we can support

KWin has such functionality, but not exposed to the js API:

Troubleshooting

If anything fails to work, you can re-run the command with --debug option. It will print the generated KWin script, and the output of the script from KWin. If you think it's a bug, please create an issue in GitHub.