Class: Fusuma::Plugin::Filters::LibinputDeviceFilter
- Defined in:
- lib/fusuma/plugin/filters/libinput_device_filter.rb
Overview
Filter device log
Defined Under Namespace
Classes: KeepDevice
Constant Summary collapse
- DEFAULT_SOURCE =
"libinput_command_input"
Instance Method Summary collapse
-
#config_param_sample ⇒ Object
: () -> String.
-
#config_param_types ⇒ Object
: () -> Hash[Symbol, Array | Class].
-
#keep?(record) ⇒ TrueClass, FalseClass
: (Fusuma::Plugin::Events::Records::TextRecord) -> bool.
-
#keep_device ⇒ Object
: () -> Fusuma::Plugin::Filters::LibinputDeviceFilter::KeepDevice.
Methods inherited from Filter
Methods inherited from Base
#config_index, #config_params, inherited, plugins, #shutdown
Instance Method Details
#config_param_sample ⇒ Object
: () -> String
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 43 def config_param_sample " ```config.yml\n plugin:\n filters:\n libinput_device_filter:\n keep_device_names:\n - \"DEVICE NAME PATTERN\"\n ```\n SAMPLE\nend\n" |
#config_param_types ⇒ Object
: () -> Hash[Symbol, Array | Class]
14 15 16 17 18 19 |
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 14 def config_param_types { source: String, keep_device_names: [Array, String] } end |
#keep?(record) ⇒ TrueClass, FalseClass
: (Fusuma::Plugin::Events::Records::TextRecord) -> bool
24 25 26 27 28 29 30 31 32 |
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 24 def keep?(record) # NOTE: purge cache when found new device if record.to_s =~ /\sDEVICE_ADDED\s/ && keep_device.match_pattern?(record.to_s) keep_device.reset return false end device_id = record.to_s.match(/\S*/, 1).to_s keep_device.all.map(&:id).include?(device_id) end |
#keep_device ⇒ Object
: () -> Fusuma::Plugin::Filters::LibinputDeviceFilter::KeepDevice
35 36 37 38 39 40 |
# File 'lib/fusuma/plugin/filters/libinput_device_filter.rb', line 35 def keep_device @keep_device ||= begin from_config = Array(config_params(:keep_device_names)) KeepDevice.new(name_patterns: from_config) end end |