Skip to main content

Live state interface for Hyprland — options, animations, monitors, binds, and devices

Project description

hyprland-state

Live state interface for Hyprland — read, write, and inspect the running compositor's configuration.

Bridges the gap between hyprland-config (disk), hyprland-socket (IPC), and hyprland-schema (metadata) into a single coherent API.

What it does

  • Options — read effective values (IPC > disk > schema default), apply changes, inspect metadata, validate against schema constraints
  • Animations — read/write animation states, manage bezier curves, navigate the animation tree
  • Monitors — read monitor layout from IPC, apply monitor configuration
  • Binds — read keybind definitions, execute dispatchers
  • Devices — detect input devices (touchpad, etc.)
  • Persistence — track pending changes, save to disk, discard/revert

Installation

pip install hyprland-state

Quick start

from hyprland_state import HyprlandState

# Schema is auto-loaded for the running Hyprland version
state = HyprlandState()

print(state.version)  # "0.54.2"

# Read the live value (typed via schema — returns int, not str)
border = state.get("general:border_size")  # 2

# Inspect schema metadata
info = state.inspect("general:border_size")
print(info.type, info.default, info.min, info.max)  # int 1 0 20

# Write to the running compositor (validated against schema)
state.apply("general:border_size", 3)
state.apply_batch([("general:gaps_in", 5), ("general:gaps_out", 10)])

# Animations
for anim in state.animations.get_all():
    print(f"{anim.name}: enabled={anim.enabled}, speed={anim.speed}")

state.animations.apply("windows", True, 3.0, "easeOut", "slide")

# Monitors
for mon in state.monitors.get_all():
    print(f"{mon.name}: {mon.width}x{mon.height}@{mon.refresh_rate}Hz")

# Devices
if state.has_touchpad():
    print("Touchpad detected")

Pending state and persistence

Changes made via apply() take effect immediately in the compositor but are tracked as pending until explicitly saved or discarded:

state.apply("general:border_size", 5)
state.apply("decoration:rounding", 10)

state.is_dirty()  # True
state.pending()   # ["general:border_size", "decoration:rounding"]

state.save()      # writes to config file and reloads compositor
# or
state.discard()   # reverts compositor to on-disk values

Validation

Values are validated against schema constraints (min/max, enum) before being sent to the compositor. Invalid values raise ValueError:

state.apply("general:border_size", 999)  # ValueError: above maximum 20

# Bypass validation when needed
state.apply("general:border_size", 999, validate=False)

Offline mode

Works without a running Hyprland instance — reads from config files and schema:

state = HyprlandState(offline=True)
value = state.get_disk("general:border_size")  # from config file
default = state.get_default("general:border_size")  # from schema

Use reconnect() to switch to online mode when the compositor becomes available:

state.reconnect()  # True if Hyprland is now reachable

Dependencies

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_state-0.1.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

hyprland_state-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file hyprland_state-0.1.0.tar.gz.

File metadata

  • Download URL: hyprland_state-0.1.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hyprland_state-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0fbc4285bb290519a0b1a6548d38ffe772079da18a020fd5aa38cbbd128e6dcf
MD5 13c5bb9f248ed53918fa41c2dfad85a1
BLAKE2b-256 f55fda13346c1ec5fd8bc49df2f1368a0f1bbc9094ed72714541e4ede2d43f6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyprland_state-0.1.0.tar.gz:

Publisher: publish.yml on BlueManCZ/hyprland-state

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_state-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hyprland_state-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hyprland_state-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2106af4df387006e3c5ec45dfa956fe357c8a853093ce33e84c68d3b54e26310
MD5 3b2228043ec6e5715012538cca539a8a
BLAKE2b-256 babd5bac897cd48847341b881788f41d631a0c571286dc0ea4cf583538e762c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyprland_state-0.1.0-py3-none-any.whl:

Publisher: publish.yml on BlueManCZ/hyprland-state

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