aioxlib
Human-friendly asyncio interface to the X11 protocol
aioxlib is a pure-Python library that speaks the X11 wire protocol over
asyncio. It aims to make displays, windows, drawing, events, and extensions
feel natural in async Python—without blocking the event loop and without
linking to libX11.
Inspired by linuxpy (same author): a clean high-level API with protocol details still available when you need them.
Features
- Fully asynchronous connection to the X server (Unix socket or TCP)
- High-level objects:
Display,Screen,Window,GC, resources - Event stream via
async for event in display.events() - Windows: create/map/configure/reparent, WM name & delete handling
- Core drawing: rectangles, arcs, segments, points, text, images
- RENDER: pictures, solid fills, gradients, triangles/trapezoids/strips, glyphs
- MIT-SHM for high-throughput image transfer
- DOUBLE-BUFFER, BIG-REQUESTS, plus GLX / DRI3 / Present helpers
- Atoms, properties (with type encode/decode), fonts, colormaps
- Python ≥ 3.12, GPLv3, no third-party runtime dependencies
- Implementation in a single module
Installation
pip install aioxlib
From source:
git clone https://codeberg.org/tiagocoutinho/aioxlib.git
cd aioxlib
pip install -e .
Quick start
import asyncio
import aioxlib
async def main():
wnd = await aioxlib.create_window(
width=640,
height=480,
title="Hello from aioxlib",
)
await wnd.show()
async for event in aioxlib.events():
if wnd.is_delete_window(event):
break
asyncio.run(main())
create_window(..., delete_on_close=True) (the default) registers
WM_DELETE_WINDOW. Use Window.is_delete_window(event) in the event loop.
Documentation
User guide and full API reference (Material for MkDocs + mkdocstrings):
pip install mkdocs mkdocs-material 'mkdocstrings[python]'
mkdocs serve
Then open http://127.0.0.1:8000/.
Examples
| File | Description |
|---|---|
basic.py |
Minimal window + close handling |
text.py |
Text on Expose |
grid.py |
Grid of filled rectangles |
points.py / segments.py |
Points and line segments |
3d.py |
Rotating mesh (Penger) |
cube_render_triangles.py |
Cube with RENDER gradients |
tristrip.py |
RENDER triangle strip |
render.py |
RENDER basics |
dbe.py / cube_dbe.py |
Double buffering |
shm.py |
MIT-SHM image path |
video.py / video_shm.py |
V4L2 video (optional) |
configure.py |
ConfigureWindow |
game_of_life.py |
Small interactive demo |
python examples/basic.py
API overview
display = await aioxlib.get_display() # or get_display(":0")
async with display:
screen = display.default_screen()
wnd = await screen.create_window(
width=800,
height=600,
title="Demo",
event_mask=aioxlib.EventMask.Exposure,
)
await wnd.show()
gc = await wnd.create_gc(foreground=0x00FFFF, background=0)
await wnd.poly_fill_rectangles(gc, [(10, 10, 100, 50)])
await wnd.poly_fill_arcs(gc, [(50, 50, 80, 80, 0, 360 * 64)])
# Optional: RENDER
render = await display.query_extension("RENDER")
if render:
formats = await render.query_picture_formats()
...
async for event in display.events():
if wnd.is_delete_window(event):
break
if event["code"] == aioxlib.EventType.Expose:
...
Events are dicts; core codes are in aioxlib.EventType.
Properties
await wnd.change_property(aioxlib.Atom.WM_NAME, aioxlib.Atom.STRING, data="Title")
reply = await wnd.get_property(aioxlib.Atom.WM_NAME)
print(reply["value"]) # decoded str / list[int] / …
Requirements
- Python ≥ 3.12
- An X11 server (Xorg, Xwayland, Xephyr, …)
$DISPLAYset, or pass the display URI explicitly
Development
pip install -e .
pip install pytest pytest-asyncio pytest-cov
pytest
License
GPLv3 or later — see LICENSE.
Author
José Tiago Macara Coutinho
https://codeberg.org/tiagocoutinho
aioxlib 0.1.0 — feedback and contributions welcome.
Release files for aioxlib 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aioxlib-0.2.0.tar.gz | 83.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioxlib-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 127.4 kB
Release files / aioxlib-0.2.0.tar.gz
| Download URL | aioxlib-0.2.0.tar.gz |
|---|---|
| Size | 83.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3473e5d89daae41cc93f4f7dd790a5787ebddfae9680651a3cc2bf98978a037b
|
|
BLAKE2b-256 checksum How to use checksums |
2620f8717c87a2c90745728e23673853b675a0048de9aa942a2ea5a771797435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / aioxlib-0.2.0-py3-none-any.whl
| Download URL | aioxlib-0.2.0-py3-none-any.whl |
|---|---|
| Size | 44.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
690098d2ca5b40663d3ecc593085557075282ab71a07d994e1b5509e17a3a59f
|
|
BLAKE2b-256 checksum How to use checksums |
76ddc83e71ede16a47b202f769fb8051e7dbbc63d77e301a30ff155554645450
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|