Skip to main content

hyprland-events

Typed event dispatch layer for Hyprland IPC. Built on top of hyprland-socket.

Every Hyprland event is parsed into a frozen dataclass with named fields — no more splitting strings on commas.

Installation

pip install hyprland-events

Usage

Blocking event loop

from hyprland_events import EventDispatcher, WorkspaceEvent, MonitorAddedEvent

dispatcher = EventDispatcher()

@dispatcher.on("workspacev2")
def on_workspace(event: WorkspaceEvent):
    print(f"Switched to workspace {event.id} ({event.name})")

@dispatcher.on("monitoraddedv2")
def on_monitor(event: MonitorAddedEvent):
    print(f"Monitor {event.name} connected")

dispatcher.run()  # blocks until the socket closes

on() also works without the decorator syntax:

dispatcher.on("workspacev2", my_handler)

GLib / GTK integration

from gi.repository import GLib
from hyprland_events import EventDispatcher

dispatcher = EventDispatcher()
dispatcher.on("configreloaded", lambda e: print("Config reloaded"))

sock, feed = dispatcher.connect()
GLib.io_add_watch(
    sock.fileno(), GLib.IO_IN,
    lambda *_: feed(sock.recv(4096)) or True,
)

Wildcard handler

dispatcher.on("*", lambda event: print(event))

One-off parsing

from hyprland_events import parse_event

event = parse_event("workspacev2", "3,code")
# WorkspaceEvent(id=3, name='code')

Supported events

Socket name Dataclass Fields
workspacev2 WorkspaceEvent id, name
focusedmonv2 FocusedMonitorEvent monitor, workspace_id
activewindow ActiveWindowEvent wm_class, title
activewindowv2 ActiveWindowV2Event address
fullscreen FullscreenEvent active
monitoraddedv2 MonitorAddedEvent id, name, description
monitorremovedv2 MonitorRemovedEvent id, name, description
createworkspacev2 CreateWorkspaceEvent id, name
destroyworkspacev2 DestroyWorkspaceEvent id, name
moveworkspacev2 MoveWorkspaceEvent id, name, monitor
renameworkspace RenameWorkspaceEvent id, name
activespecialv2 ActiveSpecialEvent id, name, monitor
activelayout ActiveLayoutEvent keyboard, layout
openwindow OpenWindowEvent address, workspace, wm_class, title
closewindow CloseWindowEvent address
movewindowv2 MoveWindowEvent address, workspace_id, workspace_name
openlayer OpenLayerEvent namespace
closelayer CloseLayerEvent namespace
submap SubmapEvent name
changefloatingmode FloatingEvent address, floating
urgent UrgentEvent address
minimized MinimizeEvent address, minimized
screencast ScreencastEvent active, owner
windowtitlev2 WindowTitleEvent address, title
configreloaded ConfigReloadedEvent (none)
pin PinEvent address, pinned
kill KillEvent address
togglegroup ToggleGroupEvent active, addresses
moveintogroup MoveIntoGroupEvent address
moveoutofgroup MoveOutOfGroupEvent address
ignoregrouplock IgnoreGroupLockEvent active
lockgroups LockGroupsEvent locked
bell BellEvent address

Unrecognized events are passed to handlers as the raw hyprland_socket.Event(name, data) object.

For sending commands and querying Hyprland state, see hyprland-socket.

License

MIT

Metadata

Release files for hyprland-events 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hyprland-events 0.4.0
File Size Uploaded
hyprland_events-0.4.0.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hyprland-events 0.4.0
File Interpreter ABI Platform
hyprland_events-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / hyprland_events-0.4.0.tar.gz

Download URL hyprland_events-0.4.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5df8aa3b4e7efbfb5a5b7ba3eca64c06a70a94c50eeeca37200b51b9531cd34b
BLAKE2b-256 checksum
How to use checksums
f110f55886cc124a215d197e90b3a05d1cfc098b916b6631a6da11b5cfa4e1e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 24, 2026.

Transparency log

Release files / hyprland_events-0.4.0-py3-none-any.whl

Download URL hyprland_events-0.4.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a44bd1808b590453b4989af071bfe1a584a4ccc49ae6e7c1407b6f67dbf4804
BLAKE2b-256 checksum
How to use checksums
fc7dff6cde55021bc1c94bec53cde10290902f3b336110588fff87a6be338db5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page