Skip to content

Hyprland

import { Aside } from “@astrojs/starlight/components”; import TypeSignature from “@components/TypeSignature.astro”;

<TypeSignature typeName={ “HyprlandError” } typePrefix={ “exception” }> HyprlandError

Bases: Exception

<TypeSignature typeName={ “HyprlandSocketError” } typePrefix={ “exception” }> HyprlandSocketError

Bases: Exception

<TypeSignature typeName={ “HyprlandSocketNotFoundError” } typePrefix={ “exception” }> HyprlandSocketNotFoundError

Bases: Exception

<TypeSignature typeName={ “HyprlandEvent” } typePrefix={ “class” } typeArgList={ “(name: str, data: list[str], raw_data: bytes)” }> HyprlandEvent

Bases: object

<TypeSignature typeName={ “name” } typePrefix={ “attribute” } returnType={ “str” }> name

the name of the received event

<TypeSignature typeName={ “data” } typePrefix={ “attribute” } returnType={ “list[str]” }> data

the data gotten from event’s body

<TypeSignature typeName={ “raw_data” } typePrefix={ “attribute” } returnType={ “bytes” }> raw_data

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

<TypeSignature typeName={ “HyprlandReply” } typePrefix={ “class” } typeArgList={ “(command: str, reply: bytes, is_ok: bool)” }> HyprlandReply

Bases: object

<TypeSignature typeName={ “command” } typePrefix={ “attribute” } returnType={ “str” }> command

the passed in command

<TypeSignature typeName={ “reply” } typePrefix={ “attribute” } returnType={ “bytes” }> reply

the raw reply from Hyprland

<TypeSignature typeName={ “is_ok” } typePrefix={ “attribute” } returnType={ “bool” }> is_ok

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)

<TypeSignature typeName={ “Hyprland” } typePrefix={ “class” } typeArgList={ “(commands_only: bool = False, **kwargs)” }> Hyprland

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

<TypeSignature typeName={ “EVENTS_SOCKET” } typePrefix={ “member” } returnType={ “None” }> EVENTS_SOCKET

<TypeSignature typeName={ “COMMANDS_SOCKET” } typePrefix={ “member” } returnType={ “None” }> COMMANDS_SOCKET

<TypeSignature typeName={ “SOCKET_PATH” } typePrefix={ “member” } returnType={ ””” }> SOCKET_PATH

<TypeSignature typeName={ “ready” } typePrefix={ “signal” } typeArgList={ “(self)” }> ready

<TypeSignature typeName={ “event” } typePrefix={ “signal” } typeArgList={ “(self, event: object)” }> event

<TypeSignature typeName={ “lookup_socket” } typePrefix={ “static” } typeArgList={ ”()” } returnType={ “tuple[UnixSocketAddress, UnixSocketAddress, str]” }> lookup_socket

<TypeSignature typeName={ “send_command” } typePrefix={ “static” } typeArgList={ “(command: str)” } returnType={ “HyprlandReply” }> send_command

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

<TypeSignature typeName={ “send_command_async” } typePrefix={ “static” } typeArgList={ “(command: str, callback: ~collections.abc.Callable[[~typing.Concatenate[~fabric.hyprland.service.HyprlandReply, ~P]], ~typing.Any] | None = None, *args: ~typing.~P, **kwargs: ~typing.~P)” } returnType={ “None” }> send_command_async

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