A Python automation toolkit that supports Wayland.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waydotool-0.1.1.tar.gz.
File metadata
- Download URL: waydotool-0.1.1.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a0d18eab70d26f25d7ae8de94c1a9c9673746531cded2d7139f8df8e2c149ac
|
|
| MD5 |
d9cb4adf2be3230ddb24ac61abbc42cb
|
|
| BLAKE2b-256 |
ed2d418c1d03467ea0fa980049dbdc67c76a521c79731f446ef5b667bb378a3f
|
File details
Details for the file waydotool-0.1.1-py3-none-any.whl.
File metadata
- Download URL: waydotool-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd34f1784669504a140d52811887c196a8b5eb1332f147ce9ee666b5952ebb96
|
|
| MD5 |
292bf3f596e96862e8c187b08f21960d
|
|
| BLAKE2b-256 |
df1a622eadd8758c2b749bd3cedd440a4c732684bd1b7972ddf644a0d772d70b
|