Skip to main content

Typed event dispatch layer for Hyprland IPC

Project description

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

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_events-0.4.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

hyprland_events-0.4.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file hyprland_events-0.4.0.tar.gz.

File metadata

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

File hashes

Hashes for hyprland_events-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5df8aa3b4e7efbfb5a5b7ba3eca64c06a70a94c50eeeca37200b51b9531cd34b
MD5 afe9b4091f3738d913080a9ce72a6448
BLAKE2b-256 f110f55886cc124a215d197e90b3a05d1cfc098b916b6631a6da11b5cfa4e1e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyprland_events-0.4.0.tar.gz:

Publisher: publish.yml on BlueManCZ/hyprland-events

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_events-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hyprland_events-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a44bd1808b590453b4989af071bfe1a584a4ccc49ae6e7c1407b6f67dbf4804
MD5 244d7b66aff380f01b9a51a1a3d42a6a
BLAKE2b-256 fc7dff6cde55021bc1c94bec53cde10290902f3b336110588fff87a6be338db5

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyprland_events-0.4.0-py3-none-any.whl:

Publisher: publish.yml on BlueManCZ/hyprland-events

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