Skip to content

Service

Bases: Exception

exception I3SocketError

Section titled “ I3SocketError ”

Bases: I3Error

exception I3SocketNotFoundError

Section titled “ I3SocketNotFoundError ”

Bases: I3SocketError

class I3MessageType (value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Section titled “ I3MessageType ”

Bases: IntEnum

member GET_BINDING_STATE 12

Section titled “ GET_BINDING_STATE ”

member WORKSPACE_EVENT 2147483648

Section titled “ WORKSPACE_EVENT ”

member OUTPUT_EVENT 2147483649

Section titled “ OUTPUT_EVENT ”

member MODE_EVENT 2147483650

Section titled “ MODE_EVENT ”

member WINDOW_EVENT 2147483651

Section titled “ WINDOW_EVENT ”

member BARCONFIG_UPDATE_EVENT 2147483652

Section titled “ BARCONFIG_UPDATE_EVENT ”

member BINDING_EVENT 2147483653

Section titled “ BINDING_EVENT ”

member SHUTDOWN_EVENT 2147483654

Section titled “ SHUTDOWN_EVENT ”

member TICK_EVENT 2147483655

Section titled “ TICK_EVENT ”

member BAR_STATE_UPDATE_EVENT 2147483668

Section titled “ BAR_STATE_UPDATE_EVENT ”

member INPUT_EVENT 2147483669

Section titled “ INPUT_EVENT ”

class I3Event (name: str, data: dict, raw_data: bytes)

Section titled “ I3Event ”

Bases: object

attribute name str

Section titled “ name ”

the name of the received event

attribute data dict

Section titled “ data ”

the json data gotten from event’s body

attribute raw_data bytes

Section titled “ raw_data ”

the raw json data

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

Section titled “ I3Reply ”

Bases: object

attribute command str

Section titled “ command ”

the passed in command

attribute reply dict | list

Section titled “ reply ”

the raw reply from i3/sway as a dict or list

attribute is_ok bool

Section titled “ is_ok ”

this indicates if the ran command has returned a success message

class I3 (**kwargs)

Section titled “ I3 ”

Bases: Service

A connection to the i3/Sway’s IPC socket. This can be used for sending commands and receiving events.

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_PATH str | None

Section titled “ SOCKET_PATH ”

property ready bool

Section titled “ ready ”

signal event (self, event: object)

Section titled “ event ”

static lookup_socket ()str

Section titled “ lookup_socket ”

static pack (message_type: I3MessageType, payload: str = '')bytes

Section titled “ pack ”

static unpack (connection: socket)tuple[int, str]

Section titled “ unpack ”

static send_command (command: str, message_type: I3MessageType = I3MessageType.COMMAND)I3Reply

Section titled “ send_command ”

Sends a command to the i3/sway socket.

example usage: “python

I3.send_command(“workspace next”) “ :param command: The command to send. :type command: str :param message_type: The type of message to send. :type message_type: I3MessageType, optional :return: A reply object containing the data from i3/sway. :rtype: I3Reply

def event_socket_task (socket_addr: str)bool

Section titled “ event_socket_task ”

def handle_raw_event (message_type: int, payload: str)

Section titled “ handle_raw_event ”