Documentation for the i3 IPC interface:
Types
Operation = enum RunCommand = 0, GetWorkspaces = 1, Subscribe = 2, GetOutputs = 3, GetTree = 4, GetMarks = 5, GetBarConfig = 6, GetVersion = 7, GetBindingModes = 8, GetConfig = 9, SendTick = 10, Sync = 11 ## when you subscribe to events, these are the kinds of replies you get ## (the integer values are significant!)
- Source Edit
EventKind = enum Workspace = 0, Output = 1, Mode = 2, Window = 3, BarConfigUpdate = 4, Binding = 5, Shutdown = 6, Tick = 7
- Source Edit
WorkspaceEvent = ref object change*: string old*: TreeReply current*: TreeReply
- Source Edit
WindowEvent = ref object change*: string container*: TreeReply
- Source Edit
BarConfigUpdateEvent = ref object id*: string hidden_state*: string mode*: string
- Source Edit
BindingEvent = ref object change*: string binding*: BindingInfo
- Source Edit
OutputEvent = ref object change*: string
- Source Edit
ModeEvent = ref object change*: string pango_markup*: bool
- Source Edit
ShutdownEvent = ref object change*: string
- Source Edit
TickEvent = ref object first*: string payload*: JsonNode
- Source Edit
Event = ref object case kind*: EventKind of Workspace: workspace*: WorkspaceEvent of Output: output*: OutputEvent of Mode: mode*: ModeEvent of Window: window*: WindowEvent of BarConfigUpdate: bar*: BarConfigUpdateEvent of Binding: binding*: BindingEvent of Shutdown: shutdown*: ShutdownEvent of Tick: tick*: TickEvent
- Source Edit
RunCommandReply = object error*: string success*: bool parse_error*: bool
- Source Edit
WindowProperties = ref object title*: string instance*: string class*: string window_role*: string transient_or*: string
- Source Edit
TreeReply = ref object id*: int name*: string pid*: int app_id*: string `type`*: string border*: string current_border_width*: int layout*: string orientation*: string percent*: float rect*: Rect window_rect*: Rect deco_rect*: Rect geometry*: Rect window*: int window_properties*: WindowProperties urgent*: bool focused*: bool sticky*: bool fullscreen_mode*: int focus*: seq[int] nodes*: seq[TreeReply] floating_nodes*: seq[TreeReply]
- Source Edit
BarConfigReplyKind = enum BarNames, OneBar
- Source Edit
BarConfigReply = object case kind*: BarConfigReplyKind of BarNames: names*: seq[string] of OneBar: config*: OneBarConfig
- Source Edit
BindingInfo = object command*: string input_code*: int symbol*: string input_type*: string event_state_mask*: seq[string]
- Source Edit
Rect = object x*: int y*: int height*: int width*: int
- Source Edit
Compositor = object socket*: AsyncSocket
- Source Edit
ReceiptKind = enum ReplyReceipt, EventReceipt
- Source Edit
Receipt = object data*: string case kind*: ReceiptKind of ReplyReceipt: reply*: Reply of EventReceipt: event*: Event
- Source Edit
ReceiptType = BitsRange[Header.mtype]
- Source Edit
Procs
proc `$`(event: Event): string {...}{.raises: [], tags: [].}
- render an event Source Edit
proc `$`(reply: Reply): string {...}{.raises: [], tags: [].}
- render a reply Source Edit
proc newCompositor(path = ""): Future[Compositor] {...}{. raises: [Exception, ValueError], tags: [RootEffect, ReadEnvEffect].}
- connect to a compositor on the given path, defaulting to sway Source Edit
proc send(kind: Operation; compositor: Compositor; payload = ""): Future[ Compositor] {...}{.raises: [Exception, ValueError], tags: [WriteIOEffect, RootEffect].}
- given an operation, send a payload to a compositor; yield the compositor Source Edit
proc send(kind: Operation; payload = ""; socket = ""): Future[Compositor] {...}{. raises: [Exception, ValueError], tags: [RootEffect, ReadEnvEffect, WriteIOEffect].}
- given an operation, send a payload to a socket; yield the compositor Source Edit
proc recv(comp: Compositor): Future[Receipt] {...}{.raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect].}
- receive a message from the compositor asynchronously Source Edit
proc newReply(kind: Operation; js: JsonNode): Reply {...}{. raises: [KeyError, ValueError, JsonKindError], tags: [].}
- parse a reply for the given operation using a JsonNode Source Edit
proc newReply(kind: Operation; payload: string): Reply {...}{.raises: [KeyError, ValueError, JsonKindError, IOError, OSError, JsonParsingError, Exception], tags: [ReadIOEffect, WriteIOEffect].}
- parse a reply for the given operation using json in a string Source Edit
proc newEvent(kind: EventKind; js: JsonNode): Event {...}{. raises: [KeyError, ValueError, JsonKindError], tags: [].}
- instantiate a new event of the given kind, parsing the json input payload from a string Source Edit
proc newEvent(kind: EventKind; payload: string): Event {...}{.raises: [KeyError, ValueError, JsonKindError, IOError, OSError, JsonParsingError, Exception], tags: [ReadIOEffect, WriteIOEffect].}
- parse an event of the given kind using json in a string Source Edit
proc invoke(compositor: Compositor; operation: Operation; args: seq[string]): Future[ Reply] {...}{.raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect].}
- perform an invocation of the given operation asynchronously Source Edit
proc invoke(compositor: Compositor; operation: Operation; args: varargs[string, `$`]): Reply {...}{. raises: [Exception, ValueError, OSError], tags: [RootEffect, TimeEffect, WriteIOEffect].}
- perform an invocation of the given operation synchronously Source Edit
proc hasChildren(container: TreeReply): bool {...}{.raises: [], tags: [].}
- true if the container has children, floating or otherwise Source Edit
proc everyClient(container: TreeReply): seq[TreeReply] {...}{.raises: [], tags: [].}
- produces a sequence of all leaves (child-free containers) in the given tree Source Edit
Iterators
iterator children(container: TreeReply): TreeReply {...}{.raises: [], tags: [].}
- yields all child containers of this container, omitting the input Source Edit
iterator clientWalk(container: TreeReply): TreeReply {...}{.raises: [], tags: [].}
- yields children of this container if they exist, otherwise yields itself Source Edit
Templates
template isFullscreen(tree: TreeReply): bool
- Source Edit