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: InvalidOption, NotInstalledError

Instance Method Summary collapse

Constructor Details

#initializeWmctrlExecutor

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_typesObject



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

Parameters:

  • event (Event)

Returns:

  • (TrueClass, FalseClass)


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

Parameters:

  • event (Event)

Returns:

  • (nil)


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_keysArray<Symbol>

executor properties on config.yml

Returns:

  • (Array<Symbol>)


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

Parameters:

  • event (Event)

Returns:

  • (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.message)
  exit 1
end