fusuma 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31810cc1a7b95244f5d8ad8a70dfd58dbefc9505
4
- data.tar.gz: e125f50146a9a43a6f2778f2908ece4d076413b0
3
+ metadata.gz: dc924ac29b2c4dbdb4af8a4244f3562f8c691e13
4
+ data.tar.gz: cfc5aed1ddfa5ef0e5c3804344159f9a4275fb26
5
5
  SHA512:
6
- metadata.gz: cf96ebc00127e1365d00ab306b06c8dc49376a1558b48ad765b4edce77e99613b4a96340188d5387f4863c18c95130f57a81922c521c7f187d90024be67065e4
7
- data.tar.gz: 5326d9d6a307640752ab526e10b5890b64207fa076b9287f2418b43fb025903c3e67f05f52024806b0dc99802bb7a11c889d631936a34a0745947f633f1629f9
6
+ metadata.gz: e89d9e3ad941b4e87cee08f216867c89c6e57095ae6eb9d536a58f89eb7fb446378694aaa2dfc0edbb18f4f13101fa5867ac2703b9f3e400db528ade75302909
7
+ data.tar.gz: db29831ba20d5962a18a5fb8957a84eb58167a962660d900373628e442d97f3c9b77c49046fbeae824b0b658efda36e5ad6ddcf28b6a052319564b8334d04144
data/README.md CHANGED
@@ -14,7 +14,7 @@ IMPORTANT: You must be a member of the _input_ group to have permission
14
14
 
15
15
  $ sudo gpasswd -a $USER input
16
16
 
17
- You must log out and back in or restart to assign this group.
17
+ **You must log out and back in or restart** to assign this group.
18
18
 
19
19
  You need libinput release 1.0 or later. Install libinput-tools:
20
20
 
@@ -6,6 +6,7 @@ require_relative 'fusuma/swipe.rb'
6
6
  require_relative 'fusuma/pinch.rb'
7
7
  require_relative 'fusuma/multi_logger'
8
8
  require_relative 'fusuma/config.rb'
9
+ require_relative 'fusuma/device.rb'
9
10
  require 'logger'
10
11
  require 'open3'
11
12
  require 'yaml'
@@ -35,7 +36,7 @@ module Fusuma
35
36
  def read_libinput
36
37
  Open3.popen3(libinput_command) do |_i, o, _e, _w|
37
38
  o.each do |line|
38
- gesture_action = GestureAction.initialize_by(line, device_names)
39
+ gesture_action = GestureAction.initialize_by(line, Device.names)
39
40
  next if gesture_action.nil?
40
41
  @action_stack ||= ActionStack.new
41
42
  @action_stack.push gesture_action
@@ -45,48 +46,19 @@ module Fusuma
45
46
  end
46
47
  end
47
48
 
48
- def device_names
49
- return @device_names unless @device_names.nil?
50
- names = []
51
- @device_names = list_devices_logs.map do |line|
52
- MultiLogger.debug(line)
53
- name = extracted_input_device_from(line)
54
- names << name unless name.nil?
55
- next unless natural_scroll_is_available?(line)
56
- names.pop
57
- end.compact
58
- end
59
-
60
49
  private
61
50
 
62
- def list_devices_logs
63
- Open3.popen3('libinput-list-devices') do |_i, o, _e, _w|
64
- return o.to_a
65
- end
66
- end
67
-
68
51
  def libinput_command
69
52
  return @libinput_command if @libinput_command
70
53
  # NOTE: --enable-dwt means "disable while typing"
71
54
  prefix = 'stdbuf -oL --'
72
55
  command = 'libinput-debug-events --enable-dwt'
73
- device_option = if device_names.size == 1
74
- "--device /dev/input/#{device_names.first}"
56
+ device_option = if Device.names.size == 1
57
+ "--device /dev/input/#{Device.names.first}"
75
58
  end
76
59
  @libinput_command = [prefix, command, device_option].join(' ')
77
60
  MultiLogger.debug(libinput_command: @libinput_command)
78
61
  @libinput_command
79
62
  end
80
-
81
- def extracted_input_device_from(line)
82
- return unless line =~ /^Kernel: /
83
- line.match(/event[0-9]+/).to_s
84
- end
85
-
86
- def natural_scroll_is_available?(line)
87
- return false unless line =~ /^Nat.scrolling: /
88
- return false if line =~ %r{n/a}
89
- true
90
- end
91
63
  end
92
64
  end
@@ -0,0 +1,45 @@
1
+ module Fusuma
2
+ # detect input device
3
+ class Device
4
+ class << self
5
+ def names
6
+ return @names unless @names.nil?
7
+ device_names = fetch_device_names
8
+ MultiLogger.debug(device_names: device_names)
9
+ raise 'Touchpad is not found' if device_names.empty?
10
+ @names = device_names
11
+ rescue => ex
12
+ MultiLogger.error(ex.message)
13
+ exit 1
14
+ end
15
+
16
+ private
17
+
18
+ def fetch_device_names
19
+ current_device = nil
20
+ list_devices_logs.map do |line|
21
+ current_device = extracted_input_device_from(line) || current_device
22
+ next unless natural_scroll_is_available?(line)
23
+ current_device
24
+ end.compact
25
+ end
26
+
27
+ def list_devices_logs
28
+ Open3.popen3('libinput-list-devices') do |_i, o, _e, _w|
29
+ return o.to_a
30
+ end
31
+ end
32
+
33
+ def extracted_input_device_from(line)
34
+ return unless line =~ /^Kernel: /
35
+ line.match(/event[0-9]+/).to_s
36
+ end
37
+
38
+ def natural_scroll_is_available?(line)
39
+ return false unless line =~ /^Nat.scrolling: /
40
+ return false if line =~ %r{n/a}
41
+ true
42
+ end
43
+ end
44
+ end
45
+ end
@@ -9,7 +9,7 @@ module Fusuma
9
9
  attr_reader :finger, :direction, :action_type
10
10
 
11
11
  def trigger_keyevent
12
- MultiLogger.debug("trigger keyevent: #{shortcut}")
12
+ MultiLogger.info("trigger keyevent: #{shortcut}")
13
13
  exec_xdotool(shortcut)
14
14
  end
15
15
 
@@ -16,7 +16,6 @@ module Fusuma
16
16
  end
17
17
 
18
18
  def info(msg)
19
- return unless debug_mode?
20
19
  super(msg)
21
20
  end
22
21
 
@@ -31,7 +30,6 @@ module Fusuma
31
30
  end
32
31
 
33
32
  def error(msg)
34
- return unless debug_mode?
35
33
  err_logger.error(msg)
36
34
  end
37
35
 
@@ -1,3 +1,3 @@
1
1
  module Fusuma
2
- VERSION = '0.3.3'.freeze
2
+ VERSION = '0.3.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-07 00:00:00.000000000 Z
11
+ date: 2018-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,7 @@ files:
136
136
  - lib/fusuma/action_stack.rb
137
137
  - lib/fusuma/config.rb
138
138
  - lib/fusuma/config.yml
139
+ - lib/fusuma/device.rb
139
140
  - lib/fusuma/gesture_action.rb
140
141
  - lib/fusuma/gesture_info.rb
141
142
  - lib/fusuma/multi_logger.rb
@@ -162,8 +163,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
163
  version: '0'
163
164
  requirements: []
164
165
  rubyforge_project:
165
- rubygems_version: 2.5.1
166
+ rubygems_version: 2.6.11
166
167
  signing_key:
167
168
  specification_version: 4
168
169
  summary: Multitouch gestures with libinput dirver on X11, Linux
169
170
  test_files: []
171
+ has_rdoc: