Class: Barr::Blocks::I3
- Inherits:
-
Barr::Block
- Object
- Barr::Block
- Barr::Blocks::I3
- Defined in:
- lib/barr/blocks/i3.rb
Instance Attribute Summary collapse
-
#focus_markers ⇒ Object
readonly
Returns the value of attribute focus_markers.
-
#i3 ⇒ Object
readonly
Returns the value of attribute i3.
-
#workspaces ⇒ Object
readonly
Returns the value of attribute workspaces.
Attributes inherited from Barr::Block
#align, #bgcolor, #fgcolor, #icon, #interval, #output
Instance Method Summary collapse
- #destroy! ⇒ Object
- #i3_connection ⇒ Object
-
#initialize(opts = {}) ⇒ I3
constructor
A new instance of I3.
- #update! ⇒ Object
Methods inherited from Barr::Block
#<<, #colors, #destroy, #draw, #reassign_deprecated_option, #update
Constructor Details
#initialize(opts = {}) ⇒ I3
Returns a new instance of I3.
10 11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#focus_markers ⇒ Object (readonly)
Returns the value of attribute focus_markers.
8 9 10 |
# File 'lib/barr/blocks/i3.rb', line 8 def focus_markers @focus_markers end |
#i3 ⇒ Object (readonly)
Returns the value of attribute i3.
8 9 10 |
# File 'lib/barr/blocks/i3.rb', line 8 def i3 @i3 end |
#workspaces ⇒ Object (readonly)
Returns the value of attribute workspaces.
8 9 10 |
# File 'lib/barr/blocks/i3.rb', line 8 def workspaces @workspaces end |
Instance Method Details
#destroy! ⇒ Object
30 31 32 |
# File 'lib/barr/blocks/i3.rb', line 30 def destroy! @i3.close end |
#i3_connection ⇒ Object
34 35 36 |
# File 'lib/barr/blocks/i3.rb', line 34 def i3_connection I3Ipc::Connection.new end |
#update! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# 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('') end |