Skip to main content

Library for controlling an X desktop Environment.

Project description

xcontroller

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 size 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

  • get the desktop geometry

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

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

    from xcontroller.keyboard import KeyboardController, SpecialKey
    
    kc = KeyboardController()
    
    kc.tap("x")
    
    kc.press(SpecialKey.ENTER)
    kc.release(SpecialKey.ENTER)
    
    with kc.pressed(SpecialKey.CTRL):
        kc.tap("s")
    
  • move the mouse pointer and click the right button

    from xcontroller.mouse import MouseController, Button
    
    mc = MouseController()
    
    mc.move(800, 500)
    mc.click(Button.RIGHT)
    
  • start an 1920x1080x24 Xvfb server on display 42

    from xcontroller.xvfb import start_xvfb
    
    process = start_xvfb(42, 1920, 1080, 24)
    

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.2.tar.gz (45.5 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.2-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xcontroller-0.2.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.2.tar.gz
Algorithm Hash digest
SHA256 ae974b59c561c5aadbdc8b0d0c7762e75b54b139dff085960f6e2a46eb0d92ab
MD5 6fa9c2e2c3abfa11ba0897640ea505f9
BLAKE2b-256 405d051fc569593ec6aae2dbed337494f283a5ffc566bd480380a09575c9f06b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xcontroller-0.2-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6673552b2e8fd16af3e97d8fc49d073b7c559b2563dfab888c63f37bd607f61a
MD5 cb9ad4e30b41f53761b3bb6e1c8e49f9
BLAKE2b-256 f573aca0b9c6b92ca5e0ca4b029a2871b48668868343f13b1741810f79f0c4bc

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