Class: Fusuma::LibinputCommands
- Inherits:
-
Object
- Object
- Fusuma::LibinputCommands
- Defined in:
- lib/fusuma/libinput_commands.rb
Overview
libinput commands wrapper
Constant Summary collapse
- NEW_CLI_OPTION_VERSION =
‘libinput-list-devices` and `libinput-debug-events` are deprecated, use `libinput list-devices` and `libinput debug-events` from 1.8.
1.8
Instance Method Summary collapse
- #debug_events {|line| ... } ⇒ Object
- #debug_events_command ⇒ Object
-
#initialize(*options) ⇒ LibinputCommands
constructor
A new instance of LibinputCommands.
- #list_devices {|line| ... } ⇒ Object
- #list_devices_command ⇒ Object
- #new_cli_option_available? ⇒ Boolean
- #version ⇒ String
-
#version_command ⇒ String
Command.
Constructor Details
#initialize(*options) ⇒ LibinputCommands
Returns a new instance of LibinputCommands.
4 5 6 |
# File 'lib/fusuma/libinput_commands.rb', line 4 def initialize(*) @options = end |
Instance Method Details
#debug_events {|line| ... } ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/fusuma/libinput_commands.rb', line 33 def debug_events prefix = 'stdbuf -oL --' = [*@options, device_option] cmd = "#{prefix} #{debug_events_command} #{.join(' ')}".strip MultiLogger.debug(debug_events: cmd) Open3.popen3(cmd) do |_i, o, _e, _w| o.each { |line| yield(line) } end end |
#debug_events_command ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/fusuma/libinput_commands.rb', line 64 def debug_events_command if new_cli_option_available? 'libinput debug-events' else 'libinput-debug-events' end end |
#list_devices {|line| ... } ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/fusuma/libinput_commands.rb', line 24 def list_devices cmd = list_devices_command MultiLogger.debug(debug_events: cmd) Open3.popen3(cmd) do |_i, o, _e, _w| o.each { |line| yield(line) } end end |
#list_devices_command ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/fusuma/libinput_commands.rb', line 56 def list_devices_command if new_cli_option_available? 'libinput list-devices' else 'libinput-list-devices' end end |
#new_cli_option_available? ⇒ Boolean
13 14 15 |
# File 'lib/fusuma/libinput_commands.rb', line 13 def new_cli_option_available? Gem::Version.new(version) >= Gem::Version.new(NEW_CLI_OPTION_VERSION) end |
#version ⇒ String
18 19 20 21 |
# File 'lib/fusuma/libinput_commands.rb', line 18 def version # versiom_command prints "1.6.3\n" @version ||= `#{version_command}`.strip end |
#version_command ⇒ String
Returns command.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fusuma/libinput_commands.rb', line 45 def version_command if which('libinput') 'libinput --version' elsif which('libinput-list-devices') 'libinput-list-devices --version' else MultiLogger.error 'install libinput-tools' exit 1 end end |