Class: Fusuma::Plugin::Executors::WmctrlExecutor

Inherits:
Executor
  • Object
show all
Defined in:
lib/fusuma/plugin/executors/wmctrl_executor.rb

Overview

Control Window or Workspaces by executing wctrl

Defined Under Namespace

Classes: Window, Workspace

Instance Method Summary collapse

Constructor Details

#initializeWmctrlExecutor

Returns a new instance of WmctrlExecutor.



23
24
25
26
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 23

def initialize
  super()
  Workspace.configure(wrap_navigation: config_params(:'wrap-navigation'))
end

Instance Method Details

#config_param_typesObject



17
18
19
20
21
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 17

def config_param_types
  {
    'wrap-navigation': [TrueClass, FalseClass]
  }
end

#executable?(event) ⇒ TrueClass, FalseClass

check executable

Parameters:

  • event (Event)

Returns:

  • (TrueClass, FalseClass)


42
43
44
45
46
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 42

def executable?(event)
  event.tag.end_with?('_detector') &&
    event.record.type == :index &&
    search_command(event)
end

#execute(event) ⇒ nil

execute wmctrl command

Parameters:

  • event (Event)

Returns:

  • (nil)


31
32
33
34
35
36
37
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 31

def execute(event)
  return if search_command(event).nil?

  MultiLogger.info(wmctrl: search_command(event))
  pid = POSIX::Spawn.spawn(search_command(event))
  Process.detach(pid)
end

#execute_keysArray<Symbol>

executor properties on config.yml

Returns:

  • (Array<Symbol>)


13
14
15
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 13

def execute_keys
  %i[wmctrl workspace]
end

#search_command(event) ⇒ String, NilClass

Parameters:

  • event (Event)

Returns:

  • (String)
  • (NilClass)


51
52
53
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 51

def search_command(event)
  search_workspace_command(event) || search_window_command(event)
end