Skip to main content

Library for controlling an X desktop Environment.

Project description

xcontroller is a Python library for developing X11 automation scripts. It includes functionality for controlling the window manager, the keyboard, and the mouse.

It is based on the following projects:

pyewmh by Julien Pagès

The functionality for controlling the window manager and windows, like getting the desktop geometry or setting the active window, are taken from this project. The code has only been refactored to follow Python style naming and some type hints were modified.

pynput by Moses Palmér

The keyboard and mouse controllers were adapted from this project. A lot of the capabilities of pynput have been left out, most importantly support for Windows and MacOS, listeners and thread safety. Type hints have been improved.

python-xvfb by Jonathan Ultis

The function for starting an Xvfb server was taken from this project with only some minor modifications.

Usage examples:

Note: All controllers take a display parameter to which they connect. If no display parameter is given, they will connect to the default display.

  • get the desktop geometry:

    from xcontroller.ewmh import WMController
    
    wm = WMController()
    width, height = wm.get_desktop_geometry()
  • find a window and raise it:

    from xcontroller.ewmh import WMController
    
    wm = WMController()
    windows = wm.get_client_list()
    for window in windows:
        if "Shell" in window.get_wm_name():
            window.raise_window()
  • Press and release keys on the keyboard:

    from xcontroller.keyboard import KeyboardController, SpecialKey
    
    kb = KeyboardController()
    
    kb.tap("x")
    
    kb.press(SpecialKey.ENTER)
    kb.release(SpecialKey.ENTER)
    
    with kb.pressed(SpecialKey.CTRL):
        kb.tap("s")
  • Start an Xvfb server:

    from xcontroller.xvfb import start_xvfb
    from pathlib import Path
    
    start_xvfb(Path("/usr/bin/Xvfb"), 1920, 1080, 24)

    Note: If no display number is given, this will choose a random number and export the DISPLAY environment variable (unless otherwise instructed).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xcontroller-0.1.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xcontroller-0.1-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

Details for the file xcontroller-0.1.tar.gz.

File metadata

  • Download URL: xcontroller-0.1.tar.gz
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xcontroller-0.1.tar.gz
Algorithm Hash digest
SHA256 0143c051a8eb0fbb28ecd8d3a356ba432b6a6b4035db7d408d92d5c6786d8477
MD5 e3829ccc81885f82e08840e79decce5c
BLAKE2b-256 6e897f3d1da862f740b8d8cc9de9197c7f78b9ea831f2f569f62618bf8e74276

See more details on using hashes here.

File details

Details for the file xcontroller-0.1-py3-none-any.whl.

File metadata

  • Download URL: xcontroller-0.1-py3-none-any.whl
  • Upload date:
  • Size: 51.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xcontroller-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae668d4103e1138227af139830420ec92435e0c205ee7f6ef67b56a27c1c80eb
MD5 42e1e856117d3d1feb426ae68eb560a8
BLAKE2b-256 20875a4e6d81094c1f4de03889f69b3d05d789fcf26f87b7e342e014df29fde5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page