Class: I3Ipc::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/i3ipc/connection.rb

Overview

Entry point for communication with i3-ipc. Able to send/receive messages and convert responses.

Usage example: con = Connection.new p con.version.human_readable # => 4.10.2 (2015-0... p con.command('focus left').success? # => true p con.workspaces[0].name # => 0 Term # ... con.close

Instance Method Summary collapse

Constructor Details

#initialize(connect = true) ⇒ Connection

Returns a new instance of Connection.



18
19
20
21
# File 'lib/i3ipc/connection.rb', line 18

def initialize(connect = true)
  @protocol = Protocol.new
  connect && @protocol.connect
end

Instance Method Details

#bar_configObject



51
52
53
# File 'lib/i3ipc/connection.rb', line 51

def bar_config
  reply_for(6)
end

#command(cmds) ⇒ Object



31
32
33
# File 'lib/i3ipc/connection.rb', line 31

def command(cmds)
  reply_for(0, cmds)
end

#connectObject



23
24
25
# File 'lib/i3ipc/connection.rb', line 23

def connect
  @protocol.connect
end

#disconnectObject



27
28
29
# File 'lib/i3ipc/connection.rb', line 27

def disconnect
  @protocol.disconnect
end

#marksObject



47
48
49
# File 'lib/i3ipc/connection.rb', line 47

def marks
  reply_for(5)
end

#outputsObject



39
40
41
# File 'lib/i3ipc/connection.rb', line 39

def outputs
  reply_for(3)
end

#treeObject



43
44
45
# File 'lib/i3ipc/connection.rb', line 43

def tree
  reply_for(4)
end

#versionObject



55
56
57
# File 'lib/i3ipc/connection.rb', line 55

def version
  reply_for(7)
end

#workspacesObject



35
36
37
# File 'lib/i3ipc/connection.rb', line 35

def workspaces
  reply_for(1)
end