Skip to main content

Monitor management utilities for Hyprland

Project description

hyprland-monitors

Monitor management utilities for Hyprland. Built on top of hyprland-socket.

Scale computation, layout geometry, config line parsing, and hardware capability detection for Hyprland monitor management.

Installation

pip install hyprland-monitors

Usage

Scale computation

Hyprland quantizes display scale to multiples of 1/120 and requires both dimensions to divide evenly. compute_valid_scales finds all valid scales for a given resolution.

from hyprland_monitors.monitors import compute_valid_scales, nearest_scale_index

scales = compute_valid_scales(3440, 1440)
for s in scales:
    print(f"  {s.label} ({s.value})")

# Find the closest valid scale to a target
idx = nearest_scale_index(scales, 1.5)
print(f"Nearest to 1.5: {scales[idx].label}")

Layout geometry

Check adjacency, detect gaps, and adjust positions when monitors resize.

from hyprland_monitors.monitors import (
    MonitorState, is_adjacent, all_monitors_connected, adjust_neighbors,
)

a = MonitorState(name="DP-1", make="", model="", width=1920, height=1080,
                 refresh_rate=60.0, x=0, y=0, scale=1.0)
b = MonitorState(name="DP-2", make="", model="", width=1920, height=1080,
                 refresh_rate=60.0, x=1920, y=0, scale=1.0)

print(is_adjacent(a, b))                # True — edge-adjacent
print(all_monitors_connected([a, b]))   # True — connected group

# After resizing a, shift b to maintain adjacency
old_w, old_h = a.effective_size
a.scale = 2.0
adjust_neighbors([a, b], a, old_w, old_h)
print(b.x)  # 960 — shifted to stay adjacent

Config line parsing

Parse and generate Hyprland monitor = config lines.

from hyprland_monitors.monitors import lines_from_monitors, parse_mode, parse_extras

lines = lines_from_monitors([a, b])
# ['DP-1, 1920x1080@60.00Hz, 0x0, 2', 'DP-2, 1920x1080@60.00Hz, 960x0, 1']

mode = parse_mode("3440x1440@165.00Hz")
# {'width': 3440, 'height': 1440, 'refresh_rate': 165.0}

extras = parse_extras("DP-1, 1920x1080@60, 0x0, 1, bitdepth, 10, vrr, 1")
# {'bit_depth': '10', 'vrr': '1'}

Hardware detection

Query monitor capabilities via EDID parsing and DRM kernel properties.

from hyprland_monitors.hardware import get_monitor_capabilities

caps = get_monitor_capabilities("DP-1")
# {'hdr': True, 'ten_bit': True, 'vrr': False}

License

MIT

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

hyprland_monitors-0.5.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

hyprland_monitors-0.5.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file hyprland_monitors-0.5.0.tar.gz.

File metadata

  • Download URL: hyprland_monitors-0.5.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hyprland_monitors-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1e2cd0f70c305f307bf57b408d0effd9c32df73d2b4b2a0184a7718217f4f683
MD5 9bfc77419d64f7fbc61da8937755ee57
BLAKE2b-256 310958667d6a9f3470992218c4c5e0afd1f87069813a1abbec582ec5c3302371

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyprland_monitors-0.5.0.tar.gz:

Publisher: publish.yml on BlueManCZ/hyprland-monitors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hyprland_monitors-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hyprland_monitors-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c4e9c779ab4dfa94f3d1574b0b4dd83978b537d0a5b6d784b6c3fb3843f110d
MD5 313fb78638a2a863b4b16bc9a9dd79ba
BLAKE2b-256 1589d40ee840788fc35d38a14945f87129e0b34eb240a711330d52397ab10f1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyprland_monitors-0.5.0-py3-none-any.whl:

Publisher: publish.yml on BlueManCZ/hyprland-monitors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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