class Fusuma::Plugin::Executors::SendkeyExecutor

Control Window or Workspaces by executing wctrl

Public Instance Methods

_execute(event) click to toggle source

execute sendkey command @param event [Event] @return [nil]

# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 36
def _execute(event)
  keyboard.type(param: search_param(event))
end
config_param_types() click to toggle source
# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 14
def config_param_types
  {
    device_name: String
  }
end
executable?(event) click to toggle source

check executable @param event [Event] @return [TrueClass, FalseClass]

# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 43
def executable?(event)
  event.tag.end_with?('_detector') &&
    event.record.type == :index &&
    keyboard.valid?(param: search_param(event))
end
execute(event) click to toggle source

fork and execute sendkey command @param event [Event] @return [nil]

# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 23
def execute(event)
  MultiLogger.info(sendkey: search_param(event))
  pid = fork do
    Process.daemon(true)
    _execute(event)
  end

  Process.detach(pid)
end
execute_keys() click to toggle source
# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 10
def execute_keys
  [:sendkey]
end

Private Instance Methods

keyboard() click to toggle source
# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 51
def keyboard
  @keyboard ||= begin
    name_pattren = config_params(:device_name)
    Sendkey::Keyboard.new(name_pattern: name_pattren)
  end
end
search_param(event) click to toggle source
# File lib/fusuma/plugin/executors/sendkey_executor.rb, line 58
def search_param(event)
  index = Config::Index.new([*event.record.index.keys, :sendkey])
  Config.search(index)
end