Skip to content

Service

Bases: Exception

exception NiriSocketError

Section titled “ NiriSocketError ”

Bases: NiriError

exception NiriSocketNotFoundError

Section titled “ NiriSocketNotFoundError ”

Bases: NiriSocketError

class NiriEvent (name: str, data: dict | list | str, raw_data: bytes)

Section titled “ NiriEvent ”

Bases: object

attribute name str

Section titled “ name ”

the name of the received event

attribute data dict | list | str

Section titled “ data ”

data gathered from the event’s body

attribute raw_data bytes

Section titled “ raw_data ”

the data as is from the socket event

class NiriReply (command: dict | list | str, reply: bytes, is_ok: bool)

Section titled “ NiriReply ”

Bases: object

attribute command dict | list | str

Section titled “ command ”

the command fed to get this reply

attribute reply bytes

Section titled “ reply ”

the reply line raw bytes raw bytes are given to avoid deserializing commands that the user typically ignores its output

attribute is_ok bool

Section titled “ is_ok ”

if the command ran successfuly or not, this is infered through a basic check (if reply has ‘Err’ in it then is_ok is False)

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

Section titled “ Niri ”

Bases: Service

a connection to a running Niri instance’s socket

Default service constructor (base constructor)

  • Parameters: **kwargs

    mapped to signal connections (e.g. on_clicked=lambda *_: … connects the given function to the signal “clicked”, notify_my_property=my_func connects the given function to the signal “notify::my-property”)

attribute SOCKET UnixSocketAddress | None

Section titled “ SOCKET ”

attribute SOCKET_PATH str

Section titled “ SOCKET_PATH ”

signal ready (self)

Section titled “ ready ”

signal event (self, event: object)

Section titled “ event ”

static lookup_socket ()tuple[UnixSocketAddress, str]

Section titled “ lookup_socket ”

def send_command (command: dict | list | str)

Section titled “ send_command ”