Class: Fusuma::Plugin::Executors::WmctrlExecutor
- Inherits:
-
Executor
- Object
- Executor
- Fusuma::Plugin::Executors::WmctrlExecutor
- Defined in:
- lib/fusuma/plugin/executors/wmctrl_executor.rb
Overview
Control Window or Workspaces by executing wctrl
Defined Under Namespace
Classes: InvalidOption, NotInstalledError
Instance Method Summary collapse
- #config_param_types ⇒ Object
-
#executable?(event) ⇒ TrueClass, FalseClass
check executable.
-
#execute(event) ⇒ nil
execute wmctrl command.
-
#execute_keys ⇒ Array<Symbol>
executor properties on config.yml.
-
#initialize ⇒ WmctrlExecutor
constructor
A new instance of WmctrlExecutor.
- #search_command(event) ⇒ String, NilClass
Constructor Details
#initialize ⇒ WmctrlExecutor
Returns a new instance of WmctrlExecutor.
27 28 29 30 31 32 33 34 |
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 27 def initialize super() @workspace = Wmctrl::Workspace.new( wrap_navigation: config_params(:"wrap-navigation"), matrix_col_size: config_params(:"matrix-col-size") ) @window = Wmctrl::Window.new end |
Instance Method Details
#config_param_types ⇒ Object
20 21 22 23 24 25 |
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 20 def config_param_types { "wrap-navigation": [TrueClass, FalseClass], "matrix-col-size": [Integer] } end |
#executable?(event) ⇒ TrueClass, FalseClass
check executable
50 51 52 53 54 |
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 50 def executable?(event) event.tag.end_with?("_detector") && event.record.type == :index && search_command(event) end |
#execute(event) ⇒ nil
execute wmctrl command
39 40 41 42 43 44 45 |
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 39 def execute(event) return if search_command(event).nil? MultiLogger.info(wmctrl: search_command(event)) pid = Process.spawn(search_command(event)) Process.detach(pid) end |
#execute_keys ⇒ Array<Symbol>
executor properties on config.yml
16 17 18 |
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 16 def execute_keys %i[workspace window] end |
#search_command(event) ⇒ String, NilClass
59 60 61 62 63 64 65 66 |
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 59 def search_command(event) must_install!("wmctrl") search_workspace_command(event) || search_window_command(event) rescue InvalidOption, NotInstalledError => e MultiLogger.error(e.) exit 1 end |