xgbutil

repository·master·Indexed 41 days ago

https://github.com/burntsushi/xgbutil

A utility library for the X Go Binding (XGB) that simplifies common X-related tasks, including key binding, window manipulation, EWMH/ICCCM compliance, and drawing images to windows.

Tokens
515
Snippets
3
Records
5
Agent score
3%

What's inside xgbutil

  1. Understand xgbutil concurrency and thread safety

    master

    Thread Safety

    xgbutil is designed to be thread-safe. While the underlying X event loop in the xevent package is implemented sequentially, you can safely assume xgbutil itself is thread-safe.

    Concurrency Model

    By default, the library follows a sequential model. The complexity of making the main event loop generally concurrent is avoided by letting the user spawn concurrent code at their own discretion. The recommended pattern is to keep the main event loop sequential and use Go's concurrency primitives for any parallel tasks.

  2. Use the write-events script to generate X event boilerplate

    master

    The write-events script is a Python program used to automate the generation of Go source files within the xevent package. It generates types_auto.go and callbacks.go, which contain the boilerplate code required for X event definitions in the core protocol. This script is essential when adding support for new X extensions (such as RandR) that require new event definitions.

    Note: This script is typically invoked automatically via make from the xgbutil root directory during the development process.

    # Typically run via make in the root directory
    make
  3. Run the window-name-sizes example

    master

    You can quickly test the library by installing and running the window-name-sizes example. This tool outputs a list of names and geometries (including window manager decorations) for all top-level windows, provided your window manager supports basic EWMH properties.

    go get github.com/BurntSushi/xgbutil/_examples/window-name-sizes
    "$GOPATH"/bin/window-name-sizes