waydotool
A Python automation toolkit that supports Wayland.
Fully typed and has docstrings. Supports Windows, macOS, Linux (X11 / Wayland).
Warnings
Work on this project is still in progress. Contributions are welcome.
Input mostly works across all platforms, with the exception of scrolling the mouse wheel being only supported on Wayland. Additionally, to query the mouse position on Wayland, only KDE Plasma >= 6 is supported. (X11/Windows/macOS is fine).
Managing Windows only works on Windows and KWin (X11 / Wayland) (you must be using KDE Plasma >= 6).
Most of it works across both Windows and KWin, with the exception that fullscreening a window is not yet implemented for Windows (for a hacky fallback, you could try focusing the window then sending the F11 keycode).
Feel free to contribute things like adding swayctl support for the window module, or your preferred Window Manager.
And no, this repository wasn't vibe coded. I did have to manually write out all the docstrings (though to be honest there was a fair bit of copying and pasting involved.)
Installation
Prerequisites
- Wayland
If you are not on Wayland, everything should work out-of-the-box.
If you are on Wayland, you will need the ydotool daemon installed and running.
If you are on Wayland but not KDE, some features will be missing.
If you are on Wayland and wlroots compositor, you will need grim for screenshots.
If you are on Wayland and KWin compositor, spectacle is used for screenshots and should be already installed.
If you are on Wayland, you need to install waydotool[wayland] to use the Portal API for streaming the screen.
Installation
$ # Wayland users:
$ pip install waydotool[wayland]
$ # Everyone else:
$ pip install waydotool
Usage
from waydotool.window import Window
from waydotool import input
import time
windows = Window.search('Firefox')
if not windows:
print("No window found.")
else:
firefox = windows[0]
firefox.activate()
time.sleep(1)
input.type('https://github.com/uukelele/waydotool')
input.key('enter')
There are a lot of exposed functions. They are all documented with docstrings so it should be easy for you to figure out how to use them.
Here are the submodules within waydotool for you to use:
- input - Use this for dealing with the mouse, keyboard, etc.
- window - Use this for modifying window state (e.g. moving, resizing, minimizing, etc.)
- clipboard - Use this for copying and pasting text from the clipboard. Note that this is simply just the
pyperclipimplementation provided in this library to make yourrequirements.txtshorter and reduce import count :D - screen - Use this for taking screenshots, or recording the screen.
Release files for waydotool 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| waydotool-0.1.1.tar.gz | 18.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| waydotool-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.9 kB
Release files / waydotool-0.1.1.tar.gz
| Download URL | waydotool-0.1.1.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a0d18eab70d26f25d7ae8de94c1a9c9673746531cded2d7139f8df8e2c149ac
|
|
BLAKE2b-256 checksum How to use checksums |
ed2d418c1d03467ea0fa980049dbdc67c76a521c79731f446ef5b667bb378a3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / waydotool-0.1.1-py3-none-any.whl
| Download URL | waydotool-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd34f1784669504a140d52811887c196a8b5eb1332f147ce9ee666b5952ebb96
|
|
BLAKE2b-256 checksum How to use checksums |
df1a622eadd8758c2b749bd3cedd440a4c732684bd1b7972ddf644a0d772d70b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|