class Barr::Blocks::I3
Attributes
focus_markers[R]
i3[R]
workspaces[R]
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
Barr::Block::new
# File lib/barr/blocks/i3.rb, line 10 def initialize(opts = {}) super @focus_markers = opts[:focus_markers] || %w(> <) @invert_focus_colors = opts[:invert_focus_colors] || false @i3 = i3_connection end
Public Instance Methods
destroy!()
click to toggle source
# File lib/barr/blocks/i3.rb, line 36 def destroy! @i3.close end
i3_connection()
click to toggle source
# File lib/barr/blocks/i3.rb, line 40 def i3_connection I3Ipc::Connection.new end
update!()
click to toggle source
# File lib/barr/blocks/i3.rb, line 18 def update! @workspaces = @i3.workspaces.map do |wsp| if wsp.focused "#{invert_colors if @invert_focus_colors}#{l_marker}#{wsp.name}#{r_marker}#{invert_colors if @invert_focus_colors}" else "%{A:barr_i3ipc \"workspace #{wsp.name.gsub(":","\\:")}\":} #{wsp.name} %{A}" end end @output = @workspaces.join('') rescue => e if e.message.match(/broken pipe/i) @i3 = i3_connection else raise end end
Private Instance Methods
l_marker()
click to toggle source
# File lib/barr/blocks/i3.rb, line 46 def l_marker @focus_markers[0] end
r_marker()
click to toggle source
# File lib/barr/blocks/i3.rb, line 50 def r_marker @focus_markers[1] end