fusuma 1.2.1 → 1.3.0

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
  SHA256:
3
- metadata.gz: f639aca336e61fc9c2a68d32bb31c52964c30eefb9c32ab2caba61dc6f37a9e7
4
- data.tar.gz: 8055c1d8250c7062f314371129d51adc54f27c4a5f7e18e07452462233047c18
3
+ metadata.gz: 548a968eabf08c31b6ed710a8cfcc698d8a4cbca97ce15b6f7850138957a9617
4
+ data.tar.gz: 7d282246f87f40834ea414cd694b945d56be4deb37f59f7f6802a1eb756d46cb
5
5
  SHA512:
6
- metadata.gz: 40f9f9aae6f9b281c474fbb65e2bb48ef4b1082c9065adbaea06dc51559504f5b652fb8716517a43d827f8b3e02f63961661d592e75fcfdf0d478c1723b9667f
7
- data.tar.gz: d3ca5a6136544f760e8277e2629838e6903f5028478fd43b647218ee19b1b4fd4a8bb744ce6e5a9b8b708614a7689cf2f6178db77180bab4105b0db55430c457
6
+ metadata.gz: c0d7dc5649dcf6ee8bc8cb5cfd3ecb590196d64fbcf175b31fdfe402b9eb81ac76d01fcd37ce630af165fc1891005fdba9c93c46b04e3a97bb73e3d3ccccef14
7
+ data.tar.gz: 1109fa1abb0afdca1b3557debc7bf0d2f1dac945d72336f6f58864ffdfe7aa2cebf0f9687b1b7ad315fffae8b142a8d22686d5b806f3babbd0142f00121a897f
@@ -1,9 +1,10 @@
1
1
  sudo: false
2
+
2
3
  language: ruby
4
+ cache: bundler
3
5
  rvm:
4
6
  - 2.3.1
5
7
  - 2.4
6
8
  - 2.5
7
- before_install:
8
- - travis_retry gem update --system || travis_retry gem update --system 2.7.8
9
- - travis_retry gem install bundler --no-document || travis_retry gem install bundler --no-document -v 1.17.3
9
+ - 2.6
10
+ before_install: gem install bundler --no-document -v 2.0.1
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.2.1](https://github.com/iberianpig/fusuma/tree/v1.2.1) (2019-10-19)
4
+ [Full Changelog](https://github.com/iberianpig/fusuma/compare/v1.2...v1.2.1)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - Fusuma must be started after connecting bluetooth trackpad [\#125](https://github.com/iberianpig/fusuma/issues/125)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - Reload Filter when new device is added [\#137](https://github.com/iberianpig/fusuma/pull/137) ([iberianpig](https://github.com/iberianpig))
13
+
14
+ ## [v1.2](https://github.com/iberianpig/fusuma/tree/v1.2) (2019-10-13)
15
+ [Full Changelog](https://github.com/iberianpig/fusuma/compare/v1.1...v1.2)
16
+
3
17
  ## [v1.1](https://github.com/iberianpig/fusuma/tree/v1.1) (2019-10-12)
4
18
  [Full Changelog](https://github.com/iberianpig/fusuma/compare/v1.0...v1.1)
5
19
 
@@ -33,8 +33,9 @@ module Fusuma
33
33
  Plugin::Manager.require_plugins_from_relative
34
34
  Plugin::Manager.require_plugins_from_config
35
35
 
36
- print_version(then_exit: option[:version])
36
+ print_version
37
37
  print_enabled_plugins
38
+ Kernel.exit(0) if option[:version]
38
39
 
39
40
  print_device_list if option[:list]
40
41
  # TODO: remove keep_device_from_option from command line options
@@ -42,8 +43,7 @@ module Fusuma
42
43
  Process.daemon if option[:daemon]
43
44
  end
44
45
 
45
- # TODO: print after reading plugins
46
- def print_version(then_exit: false)
46
+ def print_version
47
47
  MultiLogger.info '---------------------------------------------'
48
48
  MultiLogger.info "Fusuma: #{Fusuma::VERSION}"
49
49
  MultiLogger.info "libinput: #{Plugin::Inputs::LibinputCommandInput.new.version}"
@@ -51,17 +51,16 @@ module Fusuma
51
51
  MultiLogger.info "Distribution: #{`cat /etc/issue`}".strip
52
52
  MultiLogger.info "Desktop session: #{`echo $DESKTOP_SESSION`}".strip
53
53
  MultiLogger.info '---------------------------------------------'
54
- Kernel.exit(0) if then_exit
55
54
  end
56
55
 
57
56
  def print_enabled_plugins
58
- MultiLogger.debug '---------------------------------------------'
59
- MultiLogger.debug 'Enabled Plugins: '
57
+ MultiLogger.info '---------------------------------------------'
58
+ MultiLogger.info 'Enabled Plugins: '
60
59
  Plugin::Manager.plugins
61
60
  .reject { |k, _v| k.to_s =~ /Base/ }
62
61
  .map { |_base, plugins| plugins.map { |plugin| " #{plugin}" } }
63
- .flatten.sort.each { |name| MultiLogger.debug name }
64
- MultiLogger.debug '---------------------------------------------'
62
+ .flatten.sort.each { |name| MultiLogger.info(name) }
63
+ MultiLogger.info '---------------------------------------------'
65
64
  end
66
65
 
67
66
  def print_device_list
@@ -74,11 +73,6 @@ module Fusuma
74
73
 
75
74
  Config.custom_path = config_path
76
75
  end
77
-
78
- def debug_mode
79
- MultiLogger.instance.debug_mode = true
80
- print_version
81
- end
82
76
  end
83
77
 
84
78
  def initialize
@@ -97,16 +91,17 @@ module Fusuma
97
91
  parsed = parse(filtered)
98
92
  buffered = buffer(parsed)
99
93
  detected = detect(buffered)
100
- execute(detected)
94
+ merged = merge(detected)
95
+ execute(merged)
101
96
  end
102
97
  end
103
98
 
104
99
  def filter(event)
105
- @filters.reduce(event) { |e, f| f.filter(e) if e }
100
+ event if @filters.any? { |f| f.filter(event) }
106
101
  end
107
102
 
108
103
  def parse(event)
109
- @parsers.reduce(event) { |e, p| p.parse(e) if e }
104
+ @parsers.reduce(event) { |e, p| p.parse(e) if e }
110
105
  end
111
106
 
112
107
  def buffer(event)
@@ -114,28 +109,35 @@ module Fusuma
114
109
  end
115
110
 
116
111
  # @param buffers [Array<Buffer>]
117
- # @return [Event] if event is detected
118
- # @return [NilClass] if event is NOT detected
112
+ # @return [Array<Event>]
119
113
  def detect(buffers)
120
- @detectors.each_with_object([]) do |detector, index_records|
121
- event = detector.detect(buffers) # event
122
-
123
- if event&.record&.mergable?
124
- event.record.merge(records: index_records)
125
- buffers.each(&:clear) # clear buffer
126
- break(event)
114
+ @detectors.reduce([]) do |detected, detector|
115
+ if (event = detector.detect(buffers))
116
+ detected << event
117
+ else
118
+ detected
127
119
  end
128
-
129
- break nil if @detectors.last == detector
130
120
  end
131
121
  end
132
122
 
123
+ # @param events [Array<Event>]
124
+ # @return [Event] a Event merged all records from arguments
125
+ # @return [NilClass] when event is NOT given
126
+ def merge(events)
127
+ main_events, modifiers = events.partition { |event| event.record.mergable? }
128
+ return nil unless (main_event = main_events.first)
129
+
130
+ main_event.record.merge(records: modifiers.map(&:record))
131
+ main_event
132
+ end
133
+
133
134
  def execute(event)
134
135
  return unless event
135
136
 
136
137
  executor = @executors.find do |e|
137
138
  e.executable?(event)
138
139
  end
140
+
139
141
  executor&.execute(event)
140
142
  end
141
143
  end
@@ -16,7 +16,6 @@ module Fusuma
16
16
  # - window event buffer
17
17
  # - other event buffer
18
18
  return if event&.tag != source
19
- return if event.record.type != :gesture
20
19
 
21
20
  @events.push(event)
22
21
  clear unless updating?
@@ -20,10 +20,6 @@ module Fusuma
20
20
  @finger = finger
21
21
  @direction = direction
22
22
  end
23
-
24
- def type
25
- :gesture
26
- end
27
23
  end
28
24
  end
29
25
  end
@@ -9,6 +9,7 @@ module Fusuma
9
9
  class IndexRecord < Record
10
10
  # define gesture format
11
11
  attr_reader :index
12
+ attr_reader :position
12
13
 
13
14
  # @param [Config::Index] index
14
15
  # @param [Symbol] position [:prefix, :body, :surfix]
@@ -26,12 +27,12 @@ module Fusuma
26
27
  def merge(records:)
27
28
  raise "position is NOT body: #{self}" unless mergable?
28
29
 
29
- @index = records.each_with_object(@index) do |record, merged_index|
30
+ @index = records.reduce(@index) do |merged_index, record|
30
31
  case record.position
31
32
  when :prefix
32
- Index.new([*record.index.keys, *merged_index.keys])
33
+ Config::Index.new([*record.index.keys, *merged_index.keys])
33
34
  when :surfix
34
- Index.new([*merged_index.keys, *record.index.keys])
35
+ Config::Index.new([*merged_index.keys, *record.index.keys])
35
36
  else
36
37
  raise "invalid index position: #{record}"
37
38
  end
@@ -42,10 +43,6 @@ module Fusuma
42
43
  def mergable?
43
44
  @position == :body
44
45
  end
45
-
46
- protected
47
-
48
- attr_reader :position
49
46
  end
50
47
  end
51
48
  end
@@ -4,22 +4,19 @@ require_relative '../base.rb'
4
4
 
5
5
  module Fusuma
6
6
  module Plugin
7
- # filter class
8
7
  module Filters
9
- # Filter record to keep
8
+ # Filter to keep/discard events from input plugin
10
9
  class Filter < Base
11
10
  # Filter input event
12
11
  # @param event [Event]
13
- # @return [Event, nil]
12
+ # @return [Event] when keeping event
13
+ # @return [NilClass] when discarding record
14
14
  def filter(event)
15
- event.tap do |e|
16
- next if e.tag != source
17
- next if keep?(e.record)
15
+ return event if event.tag !~ /#{source}/
18
16
 
19
- MultiLogger.debug(filtered: e)
17
+ return event if keep?(event.record)
20
18
 
21
- break nil
22
- end
19
+ nil
23
20
  end
24
21
 
25
22
  # @abstract override `#keep?` to implement
@@ -10,9 +10,10 @@ module Fusuma
10
10
  class LibinputCommandInput < Input
11
11
  def config_param_types
12
12
  {
13
- 'enable-tap': [TrueClass, FalseClass],
13
+ 'device': [String],
14
14
  'enable-dwt': [TrueClass, FalseClass],
15
- 'device': [String]
15
+ 'enable-tap': [TrueClass, FalseClass],
16
+ 'show-keycodes': [TrueClass, FalseClass]
16
17
  }
17
18
  end
18
19
 
@@ -88,21 +89,21 @@ module Fusuma
88
89
  end
89
90
  end
90
91
 
91
- private
92
-
93
- # TODO: add specs
94
92
  def libinput_options
93
+ device = ("--device='#{config_params(:device)}'" if config_params(:device))
95
94
  enable_tap = '--enable-tap' if config_params(:'enable-tap')
96
- device = ("--device=#{config_params(:device)}" if config_params(:device))
97
95
  enable_dwt = '--enable-dwt' if config_params(:'enable-dwt')
98
-
96
+ show_keycodes = '--show-keycodes' if config_params(:'show-keycodes')
99
97
  [
100
- enable_tap,
101
98
  device,
102
- enable_dwt
99
+ enable_dwt,
100
+ enable_tap,
101
+ show_keycodes
103
102
  ].compact
104
103
  end
105
104
 
105
+ private
106
+
106
107
  # which in ruby: Checking if program exists in $PATH from ruby
107
108
  # (https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby)
108
109
  # Cross-platform way of finding an executable in the $PATH.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fusuma
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.0'
5
5
  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: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-19 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  requirements: []
231
- rubygems_version: 3.0.3
231
+ rubygems_version: 3.0.6
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: Multitouch gestures with libinput dirver on X11, Linux