class Widgets::Sway
Public Class Methods
Source
# File src/widgets/sway.rb, line 40 def initialize options super raise "sway: SWAYSOCK not defined" if !ENV["SWAYSOCK"] @sock = UNIXSocket.new ENV["SWAYSOCK"] #@mutex = Thread::Mutex.new read_loop get_workspaces subscribe_workspaces end
Calls superclass method
Widgets::BaseWidget::new
Public Instance Methods
Source
# File src/widgets/sway.rb, line 51 def update return unless @workspaces # we can't sort a box, so if there is a new ws we just remove all existing children new_ws = !@workspaces.map { it["id"] }.all? { children.map { it.id }.include? it } for child in children next unless child.instance_of? WorkspaceButton remove(child) unless !new_ws && @workspaces.map { it["id"] }.include?(child.id) end for ws in @workspaces.sort_by! { it["name"].to_i } if ws_button = children.find { it.id == ws["id"] } ws_button.set_focused ws["focused"] ws_button.set_urgent ws["urgent"] next end ws_button = WorkspaceButton.new(ws) ws_button.signal_connect("clicked") do @sock.write craft_message(type: MessageTypes::RUN_COMMAND, payload: "workspace #{it.name}") end append ws_button end end