Sha256: 0068c3f16abc50eb2c9645bf77d5317804fb60499104979c93de2a3dd40c2924

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require_relative './input.rb'

module Fusuma
  module Plugin
    module Inputs
      # libinput commands wrapper
      class LibinputCommandInput < Input
        def config_param_types
          {
            'device': [String],
            'enable-dwt': [TrueClass, FalseClass],
            'enable-tap': [TrueClass, FalseClass],
            'show-keycodes': [TrueClass, FalseClass],
            'verbose': [TrueClass, FalseClass]
          }
        end

        def run
          LibinputCommand.new(libinput_options: libinput_options).debug_events do |line|
            yield event(record: line)
          end
        end

        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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fusuma-1.9.0 lib/fusuma/plugin/inputs/libinput_command_input.rb
fusuma-1.8.0 lib/fusuma/plugin/inputs/libinput_command_input.rb
fusuma-1.7.0 lib/fusuma/plugin/inputs/libinput_command_input.rb