aio.Connection¶
-
class
i3ipc.aio.Connection(socket_path: Optional[str] = None, auto_reconnect: bool = False)¶ A connection to the i3 ipc used for querying window manager state and listening to events.
The
Connectionclass is the entry point into all features of the library. You must callconnect()before using thisConnection.Example: i3 = await Connection().connect() workspaces = await i3.get_workspaces() await i3.command('focus left')
Parameters: - socket_path (str) – A path to the i3 ipc socket path to connect to. If not given, find the socket path through the default search path.
- auto_reconnect (bool) – Whether to attempt to reconnect if the connection to the socket is broken when i3 restarts.
Raises: Exception – If the connection to i3 cannot be established.
-
auto_reconect¶ Whether this
Connectionwill attempt to reconnect when the connection to the socket is broken.Return type: bool
-
coroutine
command(cmd: str) → List[i3ipc.replies.CommandReply]¶ Sends a command to i3.
Parameters: cmd (str) – The command to send to i3. Returns: A list of replies that contain info for the result of each command given. Return type: list( CommandReply)
-
coroutine
connect() → i3ipc.aio.connection.Connection¶ Connects to the i3 ipc socket. You must await this method to use this Connection.
Returns: The Connection.Return type: Connection
-
coroutine
get_bar_config(bar_id=None) → Optional[i3ipc.replies.BarConfigReply]¶ Gets the bar configuration specified by the id.
Parameters: bar_id (str) – The bar id to get the configuration for. If not given, get the configuration for the first bar id. Returns: The bar configuration for the bar id. Return type: BarConfigReplyorNoneif no bar configuration is found.
-
coroutine
get_bar_config_list() → List[str]¶ Gets the names of all bar configurations.
Returns: A list of all bar configurations. Return type: list(str)
-
coroutine
get_binding_modes() → List[str]¶ Gets the names of all currently configured binding modes
Returns: A list of binding modes Return type: list(str)
-
coroutine
get_config() → i3ipc.replies.ConfigReply¶ Returns the last loaded i3 config.
Returns: A class containing the config. Return type: i3ipc.ConfigReply
-
coroutine
get_inputs() → List[i3ipc.replies.InputReply]¶ (sway only) Gets the inputs connected to the compositor.
Returns: The reply to the inputs command Return type: list( i3ipc.InputReply)
-
coroutine
get_marks() → List[str]¶ Gets the names of all currently set marks.
Returns: A list of currently set marks. Return type: list(str)
-
coroutine
get_outputs() → List[i3ipc.replies.OutputReply]¶ Gets the list of current outputs.
Returns: A list of current outputs. Return type: list( i3ipc.OutputReply)
-
coroutine
get_seats() → List[i3ipc.replies.SeatReply]¶ (sway only) Gets the seats configured on the compositor
Returns: The reply to the seats command Return type: list( i3ipc.SeatReply)
-
coroutine
get_tree() → i3ipc.aio.connection.Con¶ Gets the root container of the i3 layout tree.
Returns: The root container of the i3 layout tree. Return type: i3ipc.Con
-
coroutine
get_version() → i3ipc.replies.VersionReply¶ Gets the i3 version.
Returns: The i3 version. Return type: i3ipc.VersionReply
-
coroutine
get_workspaces() → List[i3ipc.replies.WorkspaceReply]¶ Gets the list of current workspaces.
Returns: A list of current workspaces Return type: list( i3ipc.WorkspaceReply)
-
coroutine
main()¶ Starts the main loop for this connection to start handling events.
-
main_quit(_error=None)¶ Quits the running main loop for this connection.
-
off(handler: Callable[[Connection, i3ipc.events.IpcBaseEvent], None])¶ Unsubscribe the handler from being called on ipc events.
Parameters: handler ( Callable) – The handler that was previously attached withon().
-
on(event: Union[i3ipc.events.Event, str], handler: Callable[[Connection, i3ipc.events.IpcBaseEvent], None])¶ Subscribe to the event and call the handler when it is emitted by the i3 ipc.
Parameters: - event (
Eventor str) – The event to subscribe to. - handler (
Callable) – The event handler to call.
- event (
-
coroutine
send_tick(payload: str = '') → i3ipc.replies.TickReply¶ Sends a tick with the specified payload.
Returns: The reply to the tick command Return type: i3ipc.TickReply
-
socket_path¶ The path of the socket this
Connectionis connected to.Return type: str
-
coroutine
subscribe(events: Union[List[i3ipc.events.Event], List[str]], force: bool = False)¶ Send a
SUBSCRIBEcommand to the ipc subscription connection and await the result. To attach event handlers, useConnection.on(). Calling this is only needed if you want to be notified when events will start coming in.Variables: - events (list(
Event) or list(str)) – A list of events to subscribe to. Currently you cannot subscribe to detailed events. - force (bool) – If
False, the message will not be sent if this connection is already subscribed to the event.
- events (list(