Skip to main content

wlpdisplays

A Python utility that prints connected Wayland monitor information as structured JSON by parsing wayland-info output.

AI was used during development, with parts of human code, human review and testing of all code.
This is a personal tool I wanted and I'm sharing it in case it's useful to others.


Features

  • Merges wl_output and xdg_output_v1 data from wayland-info
  • Per-monitor details: name, description, physical size, resolution, refresh rate, logical position/size, scale factors
  • Future-proof: unknown key-value fields are auto-captured with type coercion ("true"true, "42"42)
  • JSON output for easy consumption in scripts and status bars
  • Sort monitors top-left to bottom-right
  • Compact one-line output
  • --stdin mode for debugging with pre-recorded wayland-info output

Example Output

[
  {
    "name": "HDMI-A-1",
    "description": "Samsung Electric Company U28E590",
    "x": 0,
    "y": 0,
    "scale": 1.5,
    "physical_width_mm": 608,
    "physical_height_mm": 345,
    "make": "Samsung Electric Company",
    "model": "U28E590",
    "subpixel_orientation": "unknown",
    "output_transform": "normal",
    "width_px": 3840,
    "height_px": 2160,
    "refresh_hz": 60.0,
    "flags": "current",
    "output": 66,
    "logical_x": 0,
    "logical_y": 0,
    "logical_width": 2560,
    "logical_height": 1440,
    "scale_x": 1.5,
    "scale_y": 1.5,
    "int_scale": 2
  }
]

Usage

wlpdisplays [options]

Options

Flag Description
-h, --help Show help and exit
-c, --compact Print JSON on one line (no indentation)
-s, --sort Sort monitors top-left to bottom-right
-v, --version Show version and exit
-i, --stdin Read raw wayland-info data from stdin instead of running wayland-info
-w, --wayland-info-path PATH Path to the wayland-info binary (default: wayland-info)

Examples

# Normal usage
wlpdisplays

# Sorted, compact output
wlpdisplays --sort --compact

# Debug with pre-recorded output from another machine
wlpdisplays --stdin < waylandinfo-streaming-raw-out.log

Requirements

  • Python 3.9+
  • wayland-info (from wayland-utils) — not needed when using --stdin

Install on Arch Linux:

sudo pacman -S wayland-utils

Installation

As a dependency (PyPI)

pipx install wlpdisplays

or with uv:

uv tool install wlpdisplays

On many distributions a plain pip install wlpdisplays is refused due to PEP 668
("externally managed environment"). Install it in a virtual environment instead,
e.g. pipx, uv tool install, or your project's venv:

python3 -m venv .venv && source .venv/bin/activate && pip install wlpdisplays

Once installed, the wlpdisplays command is available on your PATH,
and the module can be imported in your own code.

As a single file

The entire tool lives in one self-contained file, wlpdisplays.py.
Grab it from the repo and run it directly, no install needed:

git clone https://codeberg.org/marvin1099/wlpdisplays.git
cd wlpdisplays
chmod +x wlpdisplays.py
./wlpdisplays.py

A wlpdisplays symlink to the .py file is included, so ./wlpdisplays works too.

Or download just the file:

curl -O https://codeberg.org/marvin1099/wlpdisplays/raw/branch/main/wlpdisplays.py
./wlpdisplays.py

Optionally install it into your PATH without the .py extension, user-wide (~/.local/bin) needs no sudo:

install -Dm755 wlpdisplays.py ~/.local/bin/wlpdisplays

...or system-wide:

sudo install -Dm755 wlpdisplays.py /usr/local/bin/wlpdisplays

After that, wlpdisplays is a plain command: wlpdisplays --sort --compact.


Library Usage

wlpdisplays.py is also a normal Python module, so you can use it as a library:

import wlpdisplays as wlp

# Query the running Wayland session directly
monitors = wlp.get_outputs()

# ...or push in raw wayland-info text (e.g. from a file or another machine)
with open("waylandinfo.log") as f:
    raw = f.read()
monitors = wlp.get_outputs(raw=raw)

# Sort top-left to bottom-right
monitors = wlp.get_outputs(raw=raw, sort=True)

# Compact, single-line JSON — the library equivalent of the -c flag
print(wlp.to_json(monitors, compact=True))

The data and formatting steps are separate, so you can grab monitor dicts,
work with them, and only serialize when needed.
The lower-level building blocks are still exposed:

wl_outputs, xdg_outputs = wlp.parse_wayland_info(raw)
monitors = wlp.merge_outputs(wl_outputs, xdg_outputs)

Public API:

Function Description
get_outputs(raw=None, *, sort=False, binary="wayland-info") Get monitor dicts; pass raw to skip running wayland-info
to_json(outputs, *, compact=False) Serialize monitor dicts to JSON (one line when compact)
run_wayland_info(binary="wayland-info") Run wayland-info (or binary) and return its raw output
parse_wayland_info(raw) Parse raw wayland-info text into (wl_outputs, xdg_outputs)
merge_outputs(...) Merge parsed wl_output + xdg_output_v1 data into one list
WaylandInfoError Raised when wayland-info cannot be run

Note: when used as a library, failures raise WaylandInfoError instead of exiting the process. The wlpdisplays CLI still exits with an error message.


Development

Run the test suite (stdlib only, no dependencies):

python3 -m unittest discover

Notes

This tool is designed for Wayland environments.
If run under X11 or headless setups, it will issue a warning and attempt to continue gracefully.
Unknown fields in wayland-info output are captured automatically via a key-value fallback parser
with type coercion, no code changes needed if the protocol adds new properties.

Download files

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

Source Distribution

wlpdisplays-0.2.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

wlpdisplays-0.2.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file wlpdisplays-0.2.0.tar.gz.

File metadata

  • Download URL: wlpdisplays-0.2.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for wlpdisplays-0.2.0.tar.gz
Algorithm Hash digest
SHA256 17bc3dd77c58cbd76797847cc0128f59e1e0270d2c663491b21cc42615b96399
MD5 874afaa2192d744ec7544da4258f16fc
BLAKE2b-256 32de9cc4c370fee30e4a765330151e99df0261ae44e693bfb39b0a2e6acf8d10

See more details on using hashes here.

File details

Details for the file wlpdisplays-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: wlpdisplays-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for wlpdisplays-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3b3a3faf8f0bedeb587dfb2ac6a145441197b23149f73763e4d7eb3b17b268e
MD5 f7147c96504bd0ace3f396c00b285c98
BLAKE2b-256 dc3d1973c5f2a527a0e4e8349211817583712bbb0c9f1e2298f09a07a3486eee

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