Class: Fusuma::Plugin::Inputs::LibinputCommandInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fusuma/plugin/inputs/libinput_command_input.rb

Overview

libinput commands wrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Input

#create_event, select, #tag

Methods inherited from Base

#config_index, #config_params, inherited, plugins

Methods included from CustomProcess

#fork

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



11
12
13
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 11

def pid
  @pid
end

Instance Method Details

#commandLibinputCommand

Returns:



35
36
37
38
39
40
41
42
43
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 35

def command
  @command ||= LibinputCommand.new(
    libinput_options: libinput_options,
    commands: {
      debug_events_command: debug_events_command,
      list_devices_command: list_devices_command
    }
  )
end

#config_param_typesObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 13

def config_param_types
  {
    device: [String],
    'enable-dwt': [TrueClass, FalseClass],
    'enable-tap': [TrueClass, FalseClass],
    'show-keycodes': [TrueClass, FalseClass],
    verbose: [TrueClass, FalseClass],
    'libinput-debug-events': [String],
    'libinput-list-devices': [String]
  }
end

#debug_events_commandObject



61
62
63
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 61

def debug_events_command
  config_params(:'libinput-debug-events')
end

#ioIO

Returns:



26
27
28
29
30
31
32
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 26

def io
  @io ||= begin
    reader, writer = create_io
    @pid = command.debug_events(writer)
    reader
  end
end

#libinput_optionsArray

Returns:

  • (Array)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 46

def libinput_options
  device = ("--device='#{config_params(:device)}'" if config_params(:device))
  enable_tap = '--enable-tap' if config_params(:'enable-tap')
  enable_dwt = '--enable-dwt' if config_params(:'enable-dwt')
  show_keycodes = '--show-keycodes' if config_params(:'show-keycodes')
  verbose = '--verbose' if config_params(:verbose)
  [
    device,
    enable_dwt,
    enable_tap,
    show_keycodes,
    verbose
  ].compact
end

#list_devices_commandObject



65
66
67
# File 'lib/fusuma/plugin/inputs/libinput_command_input.rb', line 65

def list_devices_command
  config_params(:'libinput-list-devices')
end