class I3::Connection


Represents a connection to a local i3 IPC server.

Defined in:



Instance Method Summary

Constructor Detail

def #

Creates a new Connection.

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

[View source]

Instance Method Detail

def 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

[View source]
def bar_ids #

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

Elements of this array can be fed into #bar_config.

[View source]
def binding_modes #

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

[View source]
def close #

Close this instance's connection to the IPC server.

[View source]
def 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"

[View source]
def config #

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

[View source]
def marks #

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

[View source]
def on_event(&block) #

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

[View source]
def outputs #

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

[View source]
def socket_path : String #

The path to the socket being used for the connection.

[View source]
def 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"]

[View source]
def subscribe(event_name : String) #

Subscribe to a single event.

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

con.subscribe "workspace"

[View source]
def tree #

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

[View source]
def version #

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

[View source]
def workspaces #

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

[View source]