lib/fusuma/plugin/executors/sendkey_executor.rb in fusuma-plugin-sendkey-0.2.1 vs lib/fusuma/plugin/executors/sendkey_executor.rb in fusuma-plugin-sendkey-0.3.0

- old
+ new

@@ -15,16 +15,14 @@ # execute sendkey command # @param event [Event] # @return [nil] def execute(event) - return if search_command(event).nil? - MultiLogger.info(sendkey: search_param(event)) pid = fork do Process.daemon(true) - exec(search_command(event)) + keyboard.type(param: search_param(event)) end Process.detach(pid) end @@ -32,24 +30,20 @@ # @param event [Event] # @return [TrueClass, FalseClass] def executable?(event) event.tag.end_with?('_detector') && event.record.type == :index && - search_command(event) + keyboard.valid?(param: search_param(event)) end - # @param event [Event] - # @return [String] - # @return [NilClass] - def search_command(event) + private + + def keyboard @keyboard ||= begin device = Sendkey::Device.new(path: config_params(:device_path)) Sendkey::Keyboard.new(device: device) end - @keyboard.type_command(param: search_param(event)) end - - private def search_param(event) index = Config::Index.new([*event.record.index.keys, :sendkey]) Config.search(index) end