Class: Fusuma::Plugin::Filters::LibinputDeviceFilter
- Inherits:
-
Filter
- Object
- Base
- Filter
- Fusuma::Plugin::Filters::LibinputDeviceFilter
show all
- Defined in:
- lib/fusuma/plugin/filters/libinput_device_filter.rb
Overview
Defined Under Namespace
Classes: KeepDevice
Constant Summary
collapse
- DEFAULT_SOURCE =
'libinput_command_input'
Instance Method Summary
collapse
Methods inherited from Filter
#filter, #source
Methods inherited from Base
#config_index, #config_params, inherited, plugins
#fork
Instance Method Details
#config_param_sample ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 38
def config_param_sample
<<~SAMPLE
```config.yml
plugin:
filters:
libinput_device_filter:
keep_device_names:
- "DEVICE NAME PATTERN"
```
SAMPLE
end
|
#config_param_types ⇒ Object
13
14
15
16
17
18
|
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 13
def config_param_types
{
source: String,
keep_device_names: [Array, String]
}
end
|
#keep?(record) ⇒ TrueClass, FalseClass
22
23
24
25
26
27
28
29
|
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 22
def keep?(record)
if record.to_s =~ /\sDEVICE_ADDED\s/ && keep_device.match_pattern?(record.to_s)
keep_device.reset
return false
end
keep_device.all.map(&:id).any? { |device_id| record.to_s =~ /^[\s-]?#{device_id}\s/ }
end
|
#keep_device ⇒ Object
31
32
33
34
35
36
|
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 31
def keep_device
@keep_device ||= begin
from_config = Array(config_params(:keep_device_names))
KeepDevice.new(name_patterns: from_config)
end
end
|