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 |
# File 'lib/barr/blocks/i3.rb', line 10 def initialize(opts = {}) super @focus_markers = opts[:focus_markers] || %w(> <) @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
29 30 31 |
# File 'lib/barr/blocks/i3.rb', line 29 def destroy! @i3.close end |
#i3_connection ⇒ Object
33 34 35 |
# File 'lib/barr/blocks/i3.rb', line 33 def i3_connection I3Ipc::Connection.new end |
#update! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/barr/blocks/i3.rb', line 17 def update! @workspaces = @i3.workspaces.map do |wsp| if wsp.focused "#{l_marker}#{wsp.name}#{r_marker}" else "%{A:barr_i3ipc workspace #{wsp.num}:} #{wsp.name} %{A}" end end @output = @workspaces.join('') end |