fusuma 2.4.1 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -0
- data/bin/console +2 -2
- data/fusuma.gemspec +17 -18
- data/lib/fusuma/config/index.rb +17 -17
- data/lib/fusuma/config/searcher.rb +1 -1
- data/lib/fusuma/config/yaml_duplication_checker.rb +7 -7
- data/lib/fusuma/config.rb +17 -13
- data/lib/fusuma/device.rb +12 -12
- data/lib/fusuma/environment.rb +10 -10
- data/lib/fusuma/hash_support.rb +1 -1
- data/lib/fusuma/libinput_command.rb +18 -19
- data/lib/fusuma/multi_logger.rb +4 -4
- data/lib/fusuma/plugin/base.rb +6 -6
- data/lib/fusuma/plugin/buffers/buffer.rb +5 -4
- data/lib/fusuma/plugin/buffers/gesture_buffer.rb +6 -6
- data/lib/fusuma/plugin/buffers/timer_buffer.rb +2 -2
- data/lib/fusuma/plugin/detectors/detector.rb +5 -5
- data/lib/fusuma/plugin/detectors/hold_detector.rb +29 -29
- data/lib/fusuma/plugin/detectors/pinch_detector.rb +47 -47
- data/lib/fusuma/plugin/detectors/rotate_detector.rb +40 -40
- data/lib/fusuma/plugin/detectors/swipe_detector.rb +43 -43
- data/lib/fusuma/plugin/events/event.rb +11 -11
- data/lib/fusuma/plugin/events/records/gesture_record.rb +5 -5
- data/lib/fusuma/plugin/events/records/index_record.rb +5 -5
- data/lib/fusuma/plugin/events/records/record.rb +2 -2
- data/lib/fusuma/plugin/events/records/text_record.rb +1 -1
- data/lib/fusuma/plugin/executors/command_executor.rb +4 -4
- data/lib/fusuma/plugin/executors/executor.rb +3 -3
- data/lib/fusuma/plugin/filters/filter.rb +3 -3
- data/lib/fusuma/plugin/filters/libinput_device_filter.rb +12 -12
- data/lib/fusuma/plugin/inputs/input.rb +8 -8
- data/lib/fusuma/plugin/inputs/libinput_command_input.rb +13 -13
- data/lib/fusuma/plugin/inputs/timer_input.rb +3 -3
- data/lib/fusuma/plugin/manager.rb +58 -31
- data/lib/fusuma/plugin/parsers/libinput_gesture_parser.rb +10 -10
- data/lib/fusuma/plugin/parsers/parser.rb +3 -3
- data/lib/fusuma/string_support.rb +3 -3
- data/lib/fusuma/version.rb +1 -1
- data/lib/fusuma.rb +10 -10
- metadata +3 -79
- data/spec/helpers/config_helper.rb +0 -20
- data/spec/lib/config/searcher_spec.rb +0 -179
- data/spec/lib/config_spec.rb +0 -104
- data/spec/lib/custom_process_spec.rb +0 -29
- data/spec/lib/device_spec.rb +0 -96
- data/spec/lib/dummy_config.yml +0 -31
- data/spec/lib/fusuma_spec.rb +0 -103
- data/spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt +0 -181
- data/spec/lib/libinput-list-devices_magic_trackpad.txt +0 -51
- data/spec/lib/libinput-list-devices_razer_razer_blade.txt +0 -252
- data/spec/lib/libinput-list-devices_thejinx0r.txt +0 -361
- data/spec/lib/libinput-list-devices_unavailable.txt +0 -36
- data/spec/lib/libinput_command_spec.rb +0 -164
- data/spec/lib/plugin/base_spec.rb +0 -74
- data/spec/lib/plugin/buffers/buffer_spec.rb +0 -80
- data/spec/lib/plugin/buffers/dummy_buffer.rb +0 -20
- data/spec/lib/plugin/buffers/gesture_buffer_spec.rb +0 -192
- data/spec/lib/plugin/detectors/detector_spec.rb +0 -43
- data/spec/lib/plugin/detectors/dummy_detector.rb +0 -24
- data/spec/lib/plugin/detectors/hold_detector_spec.rb +0 -145
- data/spec/lib/plugin/detectors/pinch_detector_spec.rb +0 -119
- data/spec/lib/plugin/detectors/rotate_detector_spec.rb +0 -125
- data/spec/lib/plugin/detectors/swipe_detector_spec.rb +0 -118
- data/spec/lib/plugin/events/event_spec.rb +0 -30
- data/spec/lib/plugin/events/records/gesture_record_spec.rb +0 -22
- data/spec/lib/plugin/events/records/record_spec.rb +0 -31
- data/spec/lib/plugin/events/records/text_record_spec.rb +0 -26
- data/spec/lib/plugin/executors/command_executor_spec.rb +0 -57
- data/spec/lib/plugin/executors/executor_spec.rb +0 -164
- data/spec/lib/plugin/filters/filter_spec.rb +0 -92
- data/spec/lib/plugin/filters/libinput_filter_spec.rb +0 -120
- data/spec/lib/plugin/inputs/input_spec.rb +0 -70
- data/spec/lib/plugin/inputs/libinput_command_input_spec.rb +0 -121
- data/spec/lib/plugin/inputs/timer_input_spec.rb +0 -40
- data/spec/lib/plugin/manager_spec.rb +0 -27
- data/spec/lib/plugin/parsers/libinput_gesture_parser_spec.rb +0 -76
- data/spec/lib/plugin/parsers/parser_spec.rb +0 -45
- data/spec/spec_helper.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9368eba481cbc496fb561cb449ec99c6b5f1eff8b4c8c4a9c8d61b4e7d5b4cf8
|
4
|
+
data.tar.gz: 3bea9acc54d3e2061f391ec282f9327ca2b3fd70463fa5f2394063a980b20613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2af60b07cfa18ca3b3d13eedf9b0271ff5bfdea37776e66a51e59eb33ea2e6bd35fe1fdc4724738ca3ecec37c7a6811c202c4277bf1e4ff341fda81e8fdb9f58
|
7
|
+
data.tar.gz: 4583ee8007e36e364658f02a42d5f447adb947408e690cb0f554c004672869f0304e2e674335aebc2d9a267abcb01cbe2f559845e604d4acc945620d7fada1a7
|
data/README.md
CHANGED
@@ -99,6 +99,38 @@ For sending shortcuts:
|
|
99
99
|
sudo pacman -S xdotool
|
100
100
|
```
|
101
101
|
|
102
|
+
### For Fedora
|
103
|
+
|
104
|
+
#### 1. Install libinput-tools
|
105
|
+
|
106
|
+
You need `libinput` release 1.0 or later.
|
107
|
+
|
108
|
+
```bash
|
109
|
+
sudo dnf install libinput
|
110
|
+
```
|
111
|
+
|
112
|
+
#### 2. Install Ruby
|
113
|
+
|
114
|
+
Fusuma runs in Ruby, so you must install it first.
|
115
|
+
|
116
|
+
```bash
|
117
|
+
sudo dnf install ruby
|
118
|
+
```
|
119
|
+
|
120
|
+
#### 3. Install Fusuma
|
121
|
+
|
122
|
+
```bash
|
123
|
+
sudo gem install fusuma
|
124
|
+
```
|
125
|
+
|
126
|
+
#### 4. Install xdotool (optional)
|
127
|
+
|
128
|
+
For sending shortcuts:
|
129
|
+
|
130
|
+
```bash
|
131
|
+
sudo dnf install xdotool
|
132
|
+
```
|
133
|
+
|
102
134
|
### Touchpad not working in GNOME
|
103
135
|
|
104
136
|
Ensure the touchpad events are being sent to the GNOME desktop by running the following command:
|
data/bin/console
CHANGED
data/fusuma.gemspec
CHANGED
@@ -1,30 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "fusuma/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = "fusuma"
|
9
|
+
spec.version = Fusuma::VERSION
|
10
|
+
spec.authors = ["iberianpig"]
|
11
|
+
spec.email = ["yhkyky@gmail.com"]
|
12
12
|
|
13
|
-
spec.summary
|
14
|
-
spec.description
|
15
|
-
spec.homepage
|
16
|
-
spec.license
|
13
|
+
spec.summary = "Multitouch gestures with libinput driver, Linux"
|
14
|
+
spec.description = "Fusuma is multitouch gesture recognizer. This gem makes your touchpad on Linux able to recognize swipes or pinchs and assign command to them. Read installation on Github(https://github.com/iberianpig/fusuma#installation)."
|
15
|
+
spec.homepage = "https://github.com/iberianpig/fusuma"
|
16
|
+
spec.license = "MIT"
|
17
17
|
|
18
|
-
spec.files
|
19
|
-
spec.
|
20
|
-
spec.
|
21
|
-
spec.
|
22
|
-
spec.require_paths = ['lib']
|
18
|
+
spec.files = Dir["{bin,lib,exe}/**/*", "LICENSE*", "README*", "*.gemspec"]
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
23
22
|
spec.metadata = {
|
24
|
-
|
25
|
-
|
23
|
+
"rubygems_mfa_required" => "true",
|
24
|
+
"yard.run" => "yri" # use "yard" to build full HTML docs.
|
26
25
|
}
|
27
26
|
|
28
|
-
spec.required_ruby_version =
|
27
|
+
spec.required_ruby_version = ">= 2.5.1" # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
29
28
|
# support bionic (18.04LTS) 2.5.1
|
30
29
|
end
|
data/lib/fusuma/config/index.rb
CHANGED
@@ -7,17 +7,17 @@ module Fusuma
|
|
7
7
|
class Index
|
8
8
|
def initialize(keys)
|
9
9
|
@keys = case keys
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
when Array
|
11
|
+
keys.map do |key|
|
12
|
+
if key.is_a? Key
|
13
|
+
key
|
14
|
+
else
|
15
|
+
Key.new(key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
[Key.new(keys)]
|
20
|
+
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def inspect
|
@@ -29,11 +29,11 @@ module Fusuma
|
|
29
29
|
def cache_key
|
30
30
|
case @keys
|
31
31
|
when Array
|
32
|
-
@keys.map(&:symbol).join(
|
32
|
+
@keys.map(&:symbol).join(",")
|
33
33
|
when Key
|
34
34
|
@keys.symbol
|
35
35
|
else
|
36
|
-
raise
|
36
|
+
raise "invalid keys"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -56,7 +56,7 @@ module Fusuma
|
|
56
56
|
def initialize(symbol_word, skippable: false, fallback: nil)
|
57
57
|
@symbol = begin
|
58
58
|
symbol_word.to_sym
|
59
|
-
rescue
|
59
|
+
rescue
|
60
60
|
symbol_word
|
61
61
|
end
|
62
62
|
|
@@ -64,14 +64,14 @@ module Fusuma
|
|
64
64
|
|
65
65
|
@fallback = begin
|
66
66
|
fallback.to_sym
|
67
|
-
rescue
|
67
|
+
rescue
|
68
68
|
fallback
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def inspect
|
73
|
-
skip_marker = @skippable && Searcher.skip? ?
|
74
|
-
fallback_marker = @fallback && Searcher.fallback? ?
|
73
|
+
skip_marker = @skippable && Searcher.skip? ? "(skip)" : ""
|
74
|
+
fallback_marker = @fallback && Searcher.fallback? ? "(fallback)" : ""
|
75
75
|
"#{@symbol}#{skip_marker}#{fallback_marker}"
|
76
76
|
end
|
77
77
|
|
@@ -7,13 +7,13 @@ module Fusuma
|
|
7
7
|
module YAMLDuplicationChecker
|
8
8
|
def self.check(yaml_string, filename, &on_duplicated)
|
9
9
|
# Ruby 2.6+
|
10
|
-
tree = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
tree = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
|
11
|
+
# Specify filename to display helpful message when it raises
|
12
|
+
# an error.
|
13
|
+
YAML.parse(yaml_string, filename: filename)
|
14
|
+
else
|
15
|
+
YAML.parse(yaml_string, filename)
|
16
|
+
end
|
17
17
|
return unless tree
|
18
18
|
|
19
19
|
traverse(tree, &on_duplicated)
|
data/lib/fusuma/config.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require
|
9
|
-
require
|
3
|
+
require_relative "./multi_logger"
|
4
|
+
require_relative "./config/index"
|
5
|
+
require_relative "./config/searcher"
|
6
|
+
require_relative "./config/yaml_duplication_checker"
|
7
|
+
require_relative "./hash_support"
|
8
|
+
require "singleton"
|
9
|
+
require "yaml"
|
10
10
|
|
11
11
|
# module as namespace
|
12
12
|
module Fusuma
|
@@ -51,6 +51,9 @@ module Fusuma
|
|
51
51
|
MultiLogger.info "reload config: #{path}"
|
52
52
|
@keymap = validate(path)
|
53
53
|
self
|
54
|
+
rescue InvalidFileError => e
|
55
|
+
MultiLogger.error e.message
|
56
|
+
exit 1
|
54
57
|
end
|
55
58
|
|
56
59
|
# @return [Hash] If check passes
|
@@ -64,10 +67,11 @@ module Fusuma
|
|
64
67
|
raise InvalidFileError, "Detect duplicate keys #{duplicates}" unless duplicates.empty?
|
65
68
|
|
66
69
|
yamls = YAML.load_stream(File.read(path)).compact
|
67
|
-
yamls.map
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
yamls.map do |yaml|
|
71
|
+
raise InvalidFileError, "invalid config.yml: #{path}" unless yaml.is_a? Hash
|
72
|
+
|
73
|
+
yaml.deep_symbolize_keys
|
74
|
+
end
|
71
75
|
end
|
72
76
|
|
73
77
|
# @param index [Index]
|
@@ -86,13 +90,13 @@ module Fusuma
|
|
86
90
|
execute_params = search(index)
|
87
91
|
return if execute_params.nil? || !execute_params.is_a?(Hash)
|
88
92
|
|
89
|
-
@execute_keys.find { |k| execute_params.
|
93
|
+
@execute_keys.find { |k| execute_params.key?(k) }
|
90
94
|
end
|
91
95
|
|
92
96
|
private
|
93
97
|
|
94
98
|
def find_filepath
|
95
|
-
filename =
|
99
|
+
filename = "fusuma/config.yml"
|
96
100
|
if custom_path
|
97
101
|
return expand_custom_path if File.exist?(expand_custom_path)
|
98
102
|
|
data/lib/fusuma/device.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
3
|
+
require_relative "./multi_logger"
|
4
|
+
require_relative "./libinput_command"
|
5
5
|
|
6
6
|
module Fusuma
|
7
7
|
# detect input device
|
@@ -46,7 +46,7 @@ module Fusuma
|
|
46
46
|
def available
|
47
47
|
@available ||= all.select(&:available).tap do |d|
|
48
48
|
MultiLogger.debug(available_devices: d)
|
49
|
-
raise
|
49
|
+
raise "Touchpad is not found" if d.empty?
|
50
50
|
end
|
51
51
|
rescue RuntimeError => e
|
52
52
|
# FIXME: should not exit without Runner class
|
@@ -106,40 +106,40 @@ module Fusuma
|
|
106
106
|
# @return [Hash]
|
107
107
|
def extract_attribute(line:)
|
108
108
|
if (id = id_from(line))
|
109
|
-
{
|
109
|
+
{id: id}
|
110
110
|
elsif (name = name_from(line))
|
111
|
-
{
|
111
|
+
{name: name}
|
112
112
|
elsif (capabilities = capabilities_from(line))
|
113
|
-
{
|
113
|
+
{capabilities: capabilities}
|
114
114
|
elsif (available = available_from(line))
|
115
|
-
{
|
115
|
+
{available: available}
|
116
116
|
else
|
117
117
|
{}
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
121
|
def id_from(line)
|
122
|
-
line.match(
|
122
|
+
line.match("^Kernel:[[:space:]]*") do |m|
|
123
123
|
m.post_match.match(/event[0-9]+/).to_s
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
def name_from(line)
|
128
|
-
line.match(
|
128
|
+
line.match("^Device:[[:space:]]*") do |m|
|
129
129
|
m.post_match.strip
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
def capabilities_from(line)
|
134
|
-
line.match(
|
134
|
+
line.match("^Capabilities:[[:space:]]*") do |m|
|
135
135
|
m.post_match.strip
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
139
|
def available_from(line)
|
140
140
|
# NOTE: is natural scroll available?
|
141
|
-
if
|
142
|
-
return false if
|
141
|
+
if /^Nat.scrolling: /.match?(line)
|
142
|
+
return false if %r{n/a}.match?(line)
|
143
143
|
|
144
144
|
return true # disabled / enabled
|
145
145
|
end
|
data/lib/fusuma/environment.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require_relative "./version"
|
4
|
+
require_relative "./libinput_command"
|
5
|
+
require_relative "./multi_logger"
|
6
6
|
|
7
7
|
module Fusuma
|
8
8
|
# Output Environment information
|
9
9
|
class Environment
|
10
10
|
class << self
|
11
11
|
def dump_information
|
12
|
-
MultiLogger.info
|
12
|
+
MultiLogger.info "---------------------------------------------"
|
13
13
|
print_version
|
14
|
-
MultiLogger.info
|
14
|
+
MultiLogger.info "---------------------------------------------"
|
15
15
|
print_enabled_plugins
|
16
|
-
MultiLogger.info
|
16
|
+
MultiLogger.info "---------------------------------------------"
|
17
17
|
end
|
18
18
|
|
19
19
|
def print_version
|
@@ -27,11 +27,11 @@ module Fusuma
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def print_enabled_plugins
|
30
|
-
MultiLogger.info
|
30
|
+
MultiLogger.info "Enabled Plugins: "
|
31
31
|
Plugin::Manager.plugins
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
.reject { |k, _v| k.to_s =~ /Base/ }
|
33
|
+
.map { |_base, plugins| plugins.map { |plugin| " #{plugin}" } }
|
34
|
+
.flatten.sort.each { |name| MultiLogger.info(name) }
|
35
35
|
end
|
36
36
|
|
37
37
|
def print_device_list
|
data/lib/fusuma/hash_support.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "open3"
|
4
4
|
|
5
5
|
module Fusuma
|
6
6
|
# Execute libinput command
|
@@ -13,7 +13,7 @@ module Fusuma
|
|
13
13
|
|
14
14
|
# `libinput-list-devices` and `libinput-debug-events` are deprecated,
|
15
15
|
# use `libinput list-devices` and `libinput debug-events` from 1.8.
|
16
|
-
NEW_CLI_OPTION_VERSION =
|
16
|
+
NEW_CLI_OPTION_VERSION = "1.8"
|
17
17
|
|
18
18
|
# @return [Boolean]
|
19
19
|
def new_cli_option_available?
|
@@ -40,10 +40,9 @@ module Fusuma
|
|
40
40
|
# @return [Integer] return a latest line libinput debug-events
|
41
41
|
def debug_events(writer)
|
42
42
|
@debug_events ||= begin
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
pid
|
43
|
+
t = Open3.pipeline_start([debug_events_with_options], ["grep -v POINTER_ --line-buffered"],
|
44
|
+
out: writer, in: "/dev/null")
|
45
|
+
t[0].pid
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
@@ -52,12 +51,12 @@ module Fusuma
|
|
52
51
|
def version_command
|
53
52
|
if @debug_events_command && @list_devices_command
|
54
53
|
"#{@list_devices_command} --version"
|
55
|
-
elsif which(
|
56
|
-
|
57
|
-
elsif which(
|
58
|
-
|
54
|
+
elsif which("libinput")
|
55
|
+
"libinput --version"
|
56
|
+
elsif which("libinput-list-devices")
|
57
|
+
"libinput-list-devices --version"
|
59
58
|
else
|
60
|
-
MultiLogger.error
|
59
|
+
MultiLogger.error "Please install libinput-tools"
|
61
60
|
exit 1
|
62
61
|
end
|
63
62
|
end
|
@@ -66,9 +65,9 @@ module Fusuma
|
|
66
65
|
if @list_devices_command
|
67
66
|
@list_devices_command
|
68
67
|
elsif new_cli_option_available?
|
69
|
-
|
68
|
+
"libinput list-devices"
|
70
69
|
else
|
71
|
-
|
70
|
+
"libinput-list-devices"
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
@@ -76,15 +75,15 @@ module Fusuma
|
|
76
75
|
if @debug_events_command
|
77
76
|
@debug_events_command
|
78
77
|
elsif new_cli_option_available?
|
79
|
-
|
78
|
+
"libinput debug-events"
|
80
79
|
else
|
81
|
-
|
80
|
+
"libinput-debug-events"
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
85
84
|
def debug_events_with_options
|
86
|
-
prefix =
|
87
|
-
"#{prefix} #{debug_events_command} #{@libinput_options.join(
|
85
|
+
prefix = "stdbuf -oL --"
|
86
|
+
"#{prefix} #{debug_events_command} #{@libinput_options.join(" ")}".strip
|
88
87
|
end
|
89
88
|
|
90
89
|
private
|
@@ -96,8 +95,8 @@ module Fusuma
|
|
96
95
|
# which('ruby') #=> /usr/bin/ruby
|
97
96
|
# @return [String, nil]
|
98
97
|
def which(command)
|
99
|
-
exts = ENV[
|
100
|
-
ENV[
|
98
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
99
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
101
100
|
exts.each do |ext|
|
102
101
|
exe = File.join(path, "#{command}#{ext}")
|
103
102
|
return exe if File.executable?(exe) && !File.directory?(exe)
|
data/lib/fusuma/multi_logger.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
# module as namespace
|
4
4
|
module Fusuma
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "logger"
|
6
|
+
require "singleton"
|
7
7
|
# logger separate between stdout and strerr
|
8
8
|
class MultiLogger < Logger
|
9
9
|
include Singleton
|
@@ -16,9 +16,9 @@ module Fusuma
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize
|
19
|
-
filepath = self.class.instance_variable_get(
|
19
|
+
filepath = self.class.instance_variable_get(:@filepath)
|
20
20
|
if filepath
|
21
|
-
logfile = File.new(filepath,
|
21
|
+
logfile = File.new(filepath, "a")
|
22
22
|
logfile.sync = true
|
23
23
|
super(logfile)
|
24
24
|
$stderr = logfile
|
data/lib/fusuma/plugin/base.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require_relative "./manager"
|
4
|
+
require_relative "../config"
|
5
|
+
require_relative "../custom_process"
|
6
6
|
|
7
7
|
module Fusuma
|
8
8
|
module Plugin
|
@@ -44,15 +44,15 @@ module Fusuma
|
|
44
44
|
|
45
45
|
next if param_types.any? { |klass| val.is_a?(klass) }
|
46
46
|
|
47
|
-
MultiLogger.error(
|
47
|
+
MultiLogger.error("Please fix config.yml.")
|
48
48
|
MultiLogger.error(":#{base.keys.map(&:symbol)
|
49
|
-
.join(
|
49
|
+
.join(" => :")} => :#{key} should be #{param_types.join(" OR ")}.")
|
50
50
|
exit 1
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
def config_index
|
55
|
-
Config::Index.new(self.class.name.gsub(
|
55
|
+
Config::Index.new(self.class.name.gsub("Fusuma::", "").underscore.split("/"))
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../base"
|
4
4
|
|
5
5
|
module Fusuma
|
6
6
|
module Plugin
|
@@ -16,7 +16,7 @@ module Fusuma
|
|
16
16
|
|
17
17
|
# @return [String]
|
18
18
|
def type
|
19
|
-
@type ||= self.class.name.underscore.split(
|
19
|
+
@type ||= self.class.name.underscore.split("/").last.gsub("_buffer", "")
|
20
20
|
end
|
21
21
|
|
22
22
|
# @param event [Event]
|
@@ -28,7 +28,8 @@ module Fusuma
|
|
28
28
|
|
29
29
|
# clear old events
|
30
30
|
# @param current_time [Time]
|
31
|
-
def clear_expired(current_time: Time.now)
|
31
|
+
def clear_expired(current_time: Time.now)
|
32
|
+
end
|
32
33
|
|
33
34
|
# clear buffer
|
34
35
|
def clear
|
@@ -38,7 +39,7 @@ module Fusuma
|
|
38
39
|
# Set source for tag from config.yml.
|
39
40
|
# DEFAULT_SOURCE is defined in each plugins.
|
40
41
|
def source
|
41
|
-
@source ||= config_params(:source) || self.class.const_get(
|
42
|
+
@source ||= config_params(:source) || self.class.const_get(:DEFAULT_SOURCE)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "./buffer"
|
4
4
|
|
5
5
|
module Fusuma
|
6
6
|
module Plugin
|
7
7
|
module Buffers
|
8
8
|
# manage events and generate command
|
9
9
|
class GestureBuffer < Buffer
|
10
|
-
DEFAULT_SOURCE =
|
10
|
+
DEFAULT_SOURCE = "libinput_gesture_parser"
|
11
11
|
DEFAULT_SECONDS_TO_KEEP = 100
|
12
12
|
|
13
13
|
def config_param_types
|
@@ -47,7 +47,7 @@ module Fusuma
|
|
47
47
|
return false if empty?
|
48
48
|
|
49
49
|
case @events.last.record.status
|
50
|
-
when
|
50
|
+
when "end", "cancelled"
|
51
51
|
true
|
52
52
|
else
|
53
53
|
false
|
@@ -63,7 +63,7 @@ module Fusuma
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def updating_events
|
66
|
-
@events.select { |e| e.record.status ==
|
66
|
+
@events.select { |e| e.record.status == "update" }
|
67
67
|
end
|
68
68
|
|
69
69
|
# @param attr [Symbol]
|
@@ -90,7 +90,7 @@ module Fusuma
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def select_by_events(&block)
|
93
|
-
return enum_for(:select_by_events) unless
|
93
|
+
return enum_for(:select_by_events) unless block
|
94
94
|
|
95
95
|
events = @events.select(&block)
|
96
96
|
self.class.new events
|
@@ -99,7 +99,7 @@ module Fusuma
|
|
99
99
|
def select_from_last_begin
|
100
100
|
return self if empty?
|
101
101
|
|
102
|
-
index_from_last = @events.reverse.find_index { |e| e.record.status ==
|
102
|
+
index_from_last = @events.reverse.find_index { |e| e.record.status == "begin" }
|
103
103
|
return GestureBuffer.new([]) if index_from_last.nil?
|
104
104
|
|
105
105
|
index_last_begin = events.length - index_from_last - 1
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "./buffer"
|
4
4
|
|
5
5
|
module Fusuma
|
6
6
|
module Plugin
|
7
7
|
module Buffers
|
8
8
|
# manage events and generate command
|
9
9
|
class TimerBuffer < Buffer
|
10
|
-
DEFAULT_SOURCE =
|
10
|
+
DEFAULT_SOURCE = "timer_input"
|
11
11
|
DEFAULT_SECONDS_TO_KEEP = 3
|
12
12
|
|
13
13
|
def config_param_types
|