Skip to content

Hyprland

exception HyprlandError

Bases: Exception

exception HyprlandSocketError

Bases: Exception

exception HyprlandSocketNotFoundError

Bases: Exception

class HyprlandEvent (name: str, data: list[str], raw_data: bytes)

Bases: object

attribute name str

the name of the received event

attribute data list[str]

the data gotten from event’s body

attribute raw_data bytes

the data as it’s from the socket’s event, it may be formatted as following event-name>>event-data1,event-data2

class HyprlandReply (command: str, reply: bytes, is_ok: bool)

Bases: object

attribute command str

the passed in command

attribute reply bytes

the raw reply from Hyprland

attribute is_ok bool

this indicates if the ran command has returned ok or not if set to False this means either the command executation has failed or the command itself doesn’t return a indication on if it failed or not (i.e commands that return data from Hyprland)

class Hyprland (commands_only: bool = False, **kwargs)

Bases: Service

A connection to Hyprland’s socket, can do both sending commands (via a hyprctl-alike interface) and receive events

  • Parameters: commands_only (bool , optional) — set to True if you’re going to use this connection for sending commands only, defaults to False

member EVENTS_SOCKET None

member COMMANDS_SOCKET None

member SOCKET_PATH ''

signal ready (self)

signal event (self, event: object)

static lookup_socket () tuple[UnixSocketAddress, UnixSocketAddress, str]

static send_command (command: str) HyprlandReply

Send hyprctl-like commands over hyprland socket

Example usage:

# next workspace...
Hyprland.send_command("/dispatch workspace e+1")
  • Parameters: command (str) — the Hyprland command to send, see Hyprland’s wiki for more info
  • Returns: a command reply object contains the reply data from hyprland
  • Return type: HyprlandReply

static send_command_async (command: str, callback: ~collections.abc.Callable[[~typing.Concatenate[~fabric.hyprland.service.HyprlandReply, ~P]], ~typing.Any] | None = None, *args: ~typing.~P, **kwargs: ~typing.~P) None

Same as send_command but this works in an asynchronous manner

  • Parameters:
    • command (str) — the Hyprland command to send, see Hyprland’s wiki for more info
    • callback (Callable [ *[*HyprlandReply ] , Any ]) — the callback on where would you like to receive the reply of the command