Module I3ipc

A pure OCaml implementation of the i3 IPC protocol.

type protocol_error =
| No_IPC_socket
| Bad_magic_string of string
| Unexpected_eof
| Unknown_type of Stdint.Uint32.t
| Bad_reply of string

The different errors that may be raised.

val pp_protocol_error : Stdlib.Format.formatter -> protocol_error -> unit
exception Protocol_error of protocol_error
module Reply : sig ... end

Type definitions for the command replies.

module Event : sig ... end

Type definitions for the events that can be subscribed to.

Connection to i3

type connection

Type describing a connection to the i3 IPC endpoint.

val connect : unit -> connection Lwt.t

Connect to a running i3 instance.

val disconnect : connection -> unit Lwt.t

Close a connection.

Event subscription

type subscription =
| Workspace
| Output
| Mode
| Window
| BarConfig
| Binding
| Shutdown
| Tick
val subscribe : connection -> subscription list -> Reply.command_outcome Lwt.t

Subscribe to certain events.

val next_event : connection -> Event.t Lwt.t

Wait for the next event, among those subscribed to.

Commands and queries

val command : connection -> string -> Reply.command_outcome list Lwt.t

Run an i3 command. See for a list of valid commands.

val get_workspaces : connection -> Reply.workspace list Lwt.t

Get the list of current workspaces.

val get_outputs : connection -> Reply.output list Lwt.t

Get the list of current outputs.

val get_tree : connection -> Reply.node Lwt.t

Get the layout tree. i3 uses a tree data-structure to represent the layout of windows in a workspace.

val get_marks : connection -> Reply.mark list Lwt.t

Get a list of marks (identifiers of containers).

val get_bar_ids : connection -> Reply.bar_id list Lwt.t

Get the list of IDs of all configured bars.

val get_bar_config : connection -> Reply.bar_id -> Reply.bar_config Lwt.t

Get the configuration of the workspace bar with given ID.

val get_version : connection -> Reply.version Lwt.t

Get the version of i3.

val get_binding_modes : connection -> Reply.binding_modes Lwt.t

Get binding modes of i3.

val get_config : connection -> Reply.config Lwt.t

Get the config file as loaded by i3 most recently.

val send_tick : connection -> string -> bool Lwt.t

Sends a tick event with the specified payload.