class

I3::Connection

Inherits Reference < Object

Represents a connection to a local i3 IPC server.

Constructors

new

Creates a new Connection.

Raises an Error if the connection can't be created.

Source

Instance methods

bar_config(bar)

Returns a Message::Bar corresponding to the given bar ID.

Bar IDs can be retrieved via #bar_ids.

# get the config for the first bar
con.bar_config(con.bar_ids.first)
Source
bar_ids

Returns an array of strings, each identifying an i3 bar.

Elements of this array can be fed into #bar_config.

Source
binding_modes

Returns an array of strings, each signifying a currently configured binding mode.

Source
close

Close this instance's connection to the IPC server.

Source
command(cmd)

Send an (i3) command to i3.

Returns an array of Message::Status indicating the success of the commands.

# send a single command
con.command "sticky enable"

# send two commands
con.command "workspace 1; sticky enable"
Source
config

Returns a Message::Config corresponding to the running i3's most recent configuration.

Source
marks

Returns an array of strings for each container that has a mark.

Source
on_event

Yields the last unconsumed event (see classes in Message::Event).

Events are yielded in FIFO order.

con.on_event do |event|
  # check the actual event type
end
Source
outputs

Returns an array of all Message::Outputs known to i3.

Source
socket_path

The path to the socket being used for the connection.

Source
subscribe(event_names : Enumerable(String))

Subscribe to each event in event_names.

Events can be retrieved one-at-a-time via #on_event.

con.subscribe ["workspace", "output"]
Source
subscribe(event_name : String)

Subscribe to a single event.

Events can be retrieved one-at-a-time via #on_event.

con.subscribe "workspace"
Source
tree

Returns a Message::Tree corresponding to the current i3 window tree.

Source
version

Returns a Message::Version corresponding to i3's version information.

Source
workspaces

Returns an array of all Message::Workspaces known to i3.

Source