fusuma-plugin-keypress 0.4.0.pre2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/fusuma-plugin-keypress.gemspec +8 -6
- data/lib/fusuma/plugin/detectors/keypress_detector.rb +58 -13
- data/lib/fusuma/plugin/events/records/keypress_record.rb +1 -0
- data/lib/fusuma/plugin/filters/keypress_filter.rb +47 -1
- data/lib/fusuma/plugin/keypress/version.rb +1 -1
- data/lib/fusuma/plugin/parsers/keypress_parser.rb +0 -14
- data/spec/fusuma/plugin/detectors/keypress_detector_spec.rb +66 -0
- data/spec/fusuma/plugin/filters/keypress_filter_spec.rb +131 -0
- data/spec/fusuma/plugin/keypress_spec.rb +9 -0
- data/spec/helpers/config_helper.rb +16 -0
- data/spec/spec_helper.rb +18 -0
- metadata +24 -21
- data/.gitignore +0 -13
- data/.rubocop.yml +0 -17
- data/.travis.yml +0 -10
- data/CHANGELOG.md +0 -37
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -18
- data/Rakefile +0 -15
- data/lefthook.yml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4dee24a10fad696ea3f6fd58e02e1c2358f522455bc9ec4aef6bc53b2004d2c
|
4
|
+
data.tar.gz: 3e0016a1d55bc7cb4096c9a77916fa1910e8a81561992255c97b17a8a67d6ddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22187a3a208c1d0989eac56c565cf00124920bb141d38f3549743c473c0b42708256c73d6c7603c6776f245a46c3ae6df8f791ba4e51f9c09de47f529b8b008b
|
7
|
+
data.tar.gz: e7f937130567f31bb3b226b3cb502f98fff973aceb21a68813170fa77d0ea80e1e531c5fabf1e0c57e56c463072ed14a1f3e9f28fc5201eca69610cdfea56f5b
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Fusuma::Plugin::Keypress [](https://badge.fury.io/rb/fusuma-plugin-keypress) [](https://badge.fury.io/rb/fusuma-plugin-keypress) [](https://github.com/iberianpig/fusuma-plugin-keypress/actions/workflows/ubuntu.yml)
|
2
2
|
|
3
3
|
|
4
4
|
Keyboard + Touchpad combination plugin for [Fusuma](https://github.com/iberianpig/fusuma)
|
@@ -33,6 +33,7 @@ plugin:
|
|
33
33
|
|
34
34
|
## Properties
|
35
35
|
|
36
|
+
### Keypress
|
36
37
|
Add `keypress:` property in `~/.config/fusuma/config.yml`.
|
37
38
|
|
38
39
|
Keys following are available for `keypress`.
|
@@ -80,6 +81,29 @@ plugin:
|
|
80
81
|
* Swipe up/down with four fingers while keypress LEFTMETA and LEFTALT keys to change audio volume.
|
81
82
|
- If you want to combine a gesture with two keys, combine modifier keys with `+`
|
82
83
|
|
84
|
+
|
85
|
+
## Typing Gesture
|
86
|
+
|
87
|
+
`typing:` is a trigger that fires when keys other than modifier keys are pressed. This trigger provides disable-while-typing similar to libinput and syndaemon.
|
88
|
+
If you are using a keyremapper such as xkeysnail and libinput's disable-while-typing does not work, try setting it.
|
89
|
+
|
90
|
+
It can be placed in the root of yaml and configured as a gesture.
|
91
|
+
The following is a configuration that uses xinput to turn off tapping for 0.6 seconds to avoid false touches.
|
92
|
+
|
93
|
+
```yaml
|
94
|
+
typing: # disable while typing
|
95
|
+
command: |
|
96
|
+
touchpad_id=$(xinput | grep Touchpad | grep -oE "id=[0-9]*" | cut -d"=" -f 2)
|
97
|
+
xinput set-prop $touchpad_id "libinput Tapping Enabled" 0
|
98
|
+
file=/tmp/typing_command_break
|
99
|
+
touch "$file"
|
100
|
+
sleep 0.6
|
101
|
+
[ `find "$file" -mmin +0.01` ] && \
|
102
|
+
xinput set-prop $touchpad_id "libinput Tapping Enabled" 1
|
103
|
+
interval: 0.5
|
104
|
+
```
|
105
|
+
|
106
|
+
|
83
107
|
## Contributing
|
84
108
|
|
85
109
|
Bug reports and pull requests are welcome on GitHub at https://github.com/iberianpig/fusuma-plugin-keypress. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -16,14 +16,16 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
|
-
|
20
|
-
spec.
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
end
|
19
|
+
spec.files = Dir['{bin,lib,exe}/**/*', 'LICENSE*', 'README*', '*.gemspec']
|
20
|
+
spec.test_files = Dir['{test,spec,features}/**/*']
|
23
21
|
spec.bindir = 'exe'
|
24
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
23
|
spec.require_paths = ['lib']
|
26
24
|
|
27
|
-
spec.required_ruby_version = '>= 2.
|
28
|
-
|
25
|
+
spec.required_ruby_version = '>= 2.5.1' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
26
|
+
# support bionic (18.04LTS) 2.5.1
|
27
|
+
spec.add_dependency 'fusuma', '~> 2.0'
|
28
|
+
spec.metadata = {
|
29
|
+
'rubygems_mfa_required' => 'true'
|
30
|
+
}
|
29
31
|
end
|
@@ -1,13 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'set'
|
4
|
+
|
3
5
|
module Fusuma
|
4
6
|
module Plugin
|
5
7
|
module Detectors
|
6
8
|
# Detect KeypressEvent from KeypressBuffer
|
7
9
|
class KeypressDetector < Detector
|
8
|
-
SOURCES = [
|
10
|
+
SOURCES = %w[keypress].freeze
|
9
11
|
BUFFER_TYPE = 'keypress'
|
10
12
|
|
13
|
+
MODIFIER_KEYS = Set.new(%w[
|
14
|
+
CAPSLOCK
|
15
|
+
LEFTALT
|
16
|
+
LEFTCTRL
|
17
|
+
LEFTMETA
|
18
|
+
LEFTSHIFT
|
19
|
+
RIGHTALT
|
20
|
+
RIGHTCTRL
|
21
|
+
RIGHTSHIFT
|
22
|
+
RIGHTMETA
|
23
|
+
])
|
24
|
+
|
11
25
|
# Always watch buffers and detect them.
|
12
26
|
def watch?
|
13
27
|
true
|
@@ -17,28 +31,59 @@ module Fusuma
|
|
17
31
|
# @return [Event] if event is detected
|
18
32
|
# @return [NilClass] if event is NOT detected
|
19
33
|
def detect(buffers)
|
20
|
-
|
34
|
+
keypress_buffer = find_buffer(buffers)
|
21
35
|
|
22
|
-
return if
|
36
|
+
return if keypress_buffer.empty?
|
23
37
|
|
24
|
-
|
38
|
+
codes = pressed_codes(keypress_buffer.events.map(&:record))
|
25
39
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
40
|
+
return if codes.empty?
|
41
|
+
|
42
|
+
record = if codes.any? { |code| MODIFIER_KEYS.include?(code) }
|
43
|
+
Events::Records::IndexRecord.new(index: create_index(codes: codes),
|
44
|
+
position: :surfix)
|
45
|
+
else
|
46
|
+
Events::Records::IndexRecord.new(index: create_typing_index)
|
47
|
+
end
|
48
|
+
|
49
|
+
create_event(record: record)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def find_buffer(buffers)
|
55
|
+
buffers.find { |b| b.type == BUFFER_TYPE }
|
56
|
+
end
|
30
57
|
|
31
|
-
|
58
|
+
def pressed_codes(records)
|
59
|
+
codes = []
|
60
|
+
records.each do |r|
|
61
|
+
if r.status == 'pressed'
|
62
|
+
codes << r.code
|
63
|
+
else
|
64
|
+
codes.delete_if { |code| code == r.code }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
codes
|
32
68
|
end
|
33
69
|
|
34
|
-
# @param
|
70
|
+
# @param code [String]
|
35
71
|
# @return [Config::Index]
|
36
|
-
def create_index(
|
37
|
-
code = records.map(&:code).join('+')
|
72
|
+
def create_index(codes:)
|
38
73
|
Config::Index.new(
|
39
74
|
[
|
40
75
|
Config::Index::Key.new('keypress', skippable: true),
|
41
|
-
Config::Index::Key.new(
|
76
|
+
Config::Index::Key.new(codes.join('+'), skippable: true)
|
77
|
+
]
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
# @param status [String]
|
82
|
+
# @return [Config::Index]
|
83
|
+
def create_typing_index
|
84
|
+
Config::Index.new(
|
85
|
+
[
|
86
|
+
Config::Index::Key.new('typing')
|
42
87
|
]
|
43
88
|
)
|
44
89
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fusuma/device'
|
4
|
+
|
3
5
|
module Fusuma
|
4
6
|
module Plugin
|
5
7
|
module Filters
|
@@ -7,10 +9,54 @@ module Fusuma
|
|
7
9
|
class KeypressFilter < Filter
|
8
10
|
DEFAULT_SOURCE = 'libinput_command_input'
|
9
11
|
|
12
|
+
def config_param_types
|
13
|
+
{
|
14
|
+
source: String,
|
15
|
+
keep_device_names: [Array, String]
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# NOTE: example of line# Select keyboard devices for filtering devices pressed/released
|
20
|
+
# event4 KEYBOARD_KEY +4.81s KEY_LEFTSHIFT (42) pressed
|
21
|
+
# event4 KEYBOARD_KEY +4.90s KEY_LEFTSHIFT (42) released
|
22
|
+
# event4 KEYBOARD_KEY +7.39s KEY_CAPSLOCK (58) pressed
|
23
|
+
# event4 KEYBOARD_KEY +7.52s KEY_CAPSLOCK (58) released
|
24
|
+
# event4 KEYBOARD_KEY +8.98s KEY_LEFTCTRL (29) pressed
|
25
|
+
# event4 KEYBOARD_KEY +9.14s KEY_LEFTCTRL (29) released
|
26
|
+
|
10
27
|
# @return [TrueClass] when keeping it
|
11
28
|
# @return [FalseClass] when discarding it
|
12
29
|
def keep?(record)
|
13
|
-
|
30
|
+
keep_devices.any? do |d|
|
31
|
+
record.to_s =~ /#{d.id}\s+KEYBOARD_KEY\s/
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# @return [Array<Fusuma::Device>]
|
38
|
+
def keep_devices
|
39
|
+
@keep_devices ||= KeepDevice.new(config_params(:keep_device_names)).select
|
40
|
+
end
|
41
|
+
|
42
|
+
# Devices to detect key presses and releases
|
43
|
+
class KeepDevice
|
44
|
+
def initialize(names)
|
45
|
+
@names = names
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Array<Fusuma::Device>]
|
49
|
+
def select
|
50
|
+
if @names
|
51
|
+
Fusuma::Device.all.select do |d|
|
52
|
+
Array(config_params(:keep_device_names)).any? do |name|
|
53
|
+
d.name =~ name
|
54
|
+
end
|
55
|
+
end
|
56
|
+
else
|
57
|
+
Fusuma::Device.all.select { |d| d.capabilities =~ /keyboard/ }
|
58
|
+
end
|
59
|
+
end
|
14
60
|
end
|
15
61
|
end
|
16
62
|
end
|
@@ -7,18 +7,6 @@ module Fusuma
|
|
7
7
|
class KeypressParser < Parser
|
8
8
|
DEFAULT_SOURCE = 'libinput_command_input'
|
9
9
|
|
10
|
-
AVAILABLE_KEYS = %w[
|
11
|
-
CAPSLOCK
|
12
|
-
LEFTALT
|
13
|
-
LEFTCTRL
|
14
|
-
LEFTMETA
|
15
|
-
LEFTSHIFT
|
16
|
-
RIGHTALT
|
17
|
-
RIGHTCTRL
|
18
|
-
RIGHTSHIFT
|
19
|
-
RIGHTMETA
|
20
|
-
].freeze
|
21
|
-
|
22
10
|
# @param record [String]
|
23
11
|
# @return [Records::Gesture, nil]
|
24
12
|
def parse_record(record)
|
@@ -39,8 +27,6 @@ module Fusuma
|
|
39
27
|
code = matched[2] # LEFTSHIFT
|
40
28
|
status = matched[3] # pressed
|
41
29
|
|
42
|
-
return unless AVAILABLE_KEYS.include?(code)
|
43
|
-
|
44
30
|
Events::Records::KeypressRecord.new(status: status, code: code)
|
45
31
|
end
|
46
32
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require 'fusuma/plugin/detectors/detector'
|
6
|
+
require 'fusuma/plugin/buffers/buffer'
|
7
|
+
|
8
|
+
require './lib/fusuma/plugin/buffers/keypress_buffer'
|
9
|
+
require './lib/fusuma/plugin/detectors/keypress_detector'
|
10
|
+
|
11
|
+
module Fusuma
|
12
|
+
module Plugin
|
13
|
+
module Detectors
|
14
|
+
RSpec.describe KeypressDetector do
|
15
|
+
before do
|
16
|
+
@detector = KeypressDetector.new
|
17
|
+
@buffer = Buffers::KeypressBuffer.new
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#detector' do
|
21
|
+
context 'with no keypress event in buffer' do
|
22
|
+
before do
|
23
|
+
@buffer.clear
|
24
|
+
end
|
25
|
+
|
26
|
+
it { expect(@detector.detect([@buffer])).to eq nil }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with keypress events in buffer' do
|
31
|
+
before do
|
32
|
+
record = Events::Records::KeypressRecord.new(status: 'pressed', code: 'LEFTSHIFT')
|
33
|
+
event = Events::Event.new(tag: 'keypress_parser', record: record)
|
34
|
+
|
35
|
+
@buffer.buffer(event)
|
36
|
+
end
|
37
|
+
it { expect(@detector.detect([@buffer])).to be_a Events::Event }
|
38
|
+
it { expect(@detector.detect([@buffer]).record).to be_a Events::Records::IndexRecord }
|
39
|
+
it { expect(@detector.detect([@buffer]).record.index).to be_a Config::Index }
|
40
|
+
|
41
|
+
it 'should detect LEFTSHIFT' do
|
42
|
+
expect(@detector.detect([@buffer]).record.index.keys.map(&:symbol))
|
43
|
+
.to eq(%i[keypress LEFTSHIFT])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with two different keypress events in buffer' do
|
48
|
+
before do
|
49
|
+
record1 = Events::Records::KeypressRecord.new(status: 'pressed', code: 'LEFTSHIFT')
|
50
|
+
record2 = Events::Records::KeypressRecord.new(status: 'pressed', code: 'LEFTCTRL')
|
51
|
+
event1 = Events::Event.new(tag: 'keypress_parser', record: record1)
|
52
|
+
event2 = Events::Event.new(tag: 'keypress_parser', record: record2)
|
53
|
+
|
54
|
+
@buffer.buffer(event1)
|
55
|
+
@buffer.buffer(event2)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should detect LEFTSHIFT+LEFTCTRL' do
|
59
|
+
expect(@detector.detect([@buffer]).record.index.keys.map(&:symbol))
|
60
|
+
.to eq(%i[keypress LEFTSHIFT+LEFTCTRL])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require 'fusuma/plugin/filters/filter'
|
6
|
+
require 'fusuma/plugin/inputs/input'
|
7
|
+
|
8
|
+
require './lib/fusuma/plugin/filters/keypress_filter'
|
9
|
+
|
10
|
+
module Fusuma
|
11
|
+
module Plugin
|
12
|
+
module Filters
|
13
|
+
RSpec.describe KeypressFilter do
|
14
|
+
describe '#keep?' do
|
15
|
+
before { @filter = KeypressFilter.new }
|
16
|
+
context 'with keyboard event' do
|
17
|
+
before do
|
18
|
+
keyboard = double(Fusuma::Device, id: 'event4')
|
19
|
+
allow(@filter).to receive(:keep_devices).and_return([keyboard])
|
20
|
+
text = " #{keyboard.id} KEYBOARD_KEY +4.81s KEY_LEFTSHIFT (42) pressed"
|
21
|
+
@event = Events::Event.new(tag: 'libinput_command_input', record: text)
|
22
|
+
# @filter = KeypressFilter.new
|
23
|
+
end
|
24
|
+
it 'should be true' do
|
25
|
+
expect(@filter.keep?(@event.record)).to eq true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
context 'with multiple keyboards' do
|
29
|
+
before do
|
30
|
+
keyboard1 = double(Fusuma::Device, id: 'event1')
|
31
|
+
keyboard2 = double(Fusuma::Device, id: 'event2')
|
32
|
+
allow(@filter).to receive(:keep_devices).and_return([
|
33
|
+
keyboard1, keyboard2
|
34
|
+
])
|
35
|
+
text1 = " #{keyboard1.id} KEYBOARD_KEY +4.81s KEY_LEFTSHIFT (42) pressed"
|
36
|
+
text2 = " #{keyboard2.id} KEYBOARD_KEY +4.81s KEY_LEFTSHIFT (42) pressed"
|
37
|
+
@event1 = Events::Event.new(tag: 'libinput_command_input', record: text1)
|
38
|
+
@event2 = Events::Event.new(tag: 'libinput_command_input', record: text2)
|
39
|
+
end
|
40
|
+
it 'should return multiple keyboards' do
|
41
|
+
expect(@filter.keep?(@event1.record)).to eq true
|
42
|
+
expect(@filter.keep?(@event2.record)).to eq true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context 'when touchpad events' do
|
46
|
+
before do
|
47
|
+
touchpad = double(Fusuma::Device, id: 'event18')
|
48
|
+
allow(@filter).to receive(:keep_devices).and_return([touchpad])
|
49
|
+
text = " #{touchpad.id} GESTURE_SWIPE_UPDATE +1.44s 4 11.23/ 1.00 (36.91/ 3.28 unaccelerated) "
|
50
|
+
# ^^^^^^^^^^^^^^^^^^^^ Shoud be KEYBOARD_KEY
|
51
|
+
@event = Events::Event.new(tag: 'libinput_command_input', record: text)
|
52
|
+
end
|
53
|
+
it 'should be false' do
|
54
|
+
expect(@filter.keep?(@event.record)).to eq false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with plugins.filters.keypress_filter.source=CUSTOM_INPUT' do
|
59
|
+
it { expect(@filter.source).to eq 'libinput_command_input' }
|
60
|
+
|
61
|
+
context 'with config' do
|
62
|
+
around do |example|
|
63
|
+
@custom_source = 'CUSTOM_INPUT'
|
64
|
+
|
65
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
66
|
+
plugin:
|
67
|
+
filters:
|
68
|
+
keypress_filter:
|
69
|
+
source: #{@custom_source}
|
70
|
+
CONFIG
|
71
|
+
|
72
|
+
example.run
|
73
|
+
|
74
|
+
Config.custom_path = nil
|
75
|
+
end
|
76
|
+
|
77
|
+
it { expect(@filter.source).to eq @custom_source }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
context "with config file having plugins.filters.keypress.keep_device_names='CUSTOM_KEYBOARD'" do
|
81
|
+
it { expect(@filter.source).to eq 'libinput_command_input' }
|
82
|
+
|
83
|
+
context 'with config' do
|
84
|
+
around do |example|
|
85
|
+
@name = 'CUSTOM_KEYBOARD'
|
86
|
+
|
87
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
88
|
+
plugin:
|
89
|
+
filters:
|
90
|
+
keypress_filter:
|
91
|
+
keep_device_names: #{@name}
|
92
|
+
CONFIG
|
93
|
+
|
94
|
+
example.run
|
95
|
+
|
96
|
+
Config.custom_path = nil
|
97
|
+
end
|
98
|
+
|
99
|
+
it { expect(@filter.config_params[:keep_device_names]).to eq @name }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
context "with config file having plugins.filters.keypress.keep_device_names=['INTERNAL_KEYBOARD','EXTERNAL_KEYBOARD']" do
|
103
|
+
it { expect(@filter.source).to eq 'libinput_command_input' }
|
104
|
+
|
105
|
+
context 'with config' do
|
106
|
+
around do |example|
|
107
|
+
@name1 = 'INTERNAL_KEYBOARD'
|
108
|
+
@name2 = 'EXTERNAL_KEYBOARD'
|
109
|
+
|
110
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
111
|
+
plugin:
|
112
|
+
filters:
|
113
|
+
keypress_filter:
|
114
|
+
keep_device_names:
|
115
|
+
- #{@name1}
|
116
|
+
- #{@name2}
|
117
|
+
CONFIG
|
118
|
+
|
119
|
+
example.run
|
120
|
+
|
121
|
+
Config.custom_path = nil
|
122
|
+
end
|
123
|
+
|
124
|
+
it { expect(@filter.config_params(:keep_device_names)).to eq [@name1, @name2] }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
require 'fusuma/config'
|
5
|
+
|
6
|
+
module Fusuma
|
7
|
+
module ConfigHelper
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def load_config_yml=(string)
|
11
|
+
Config.custom_path = Tempfile.open do |temp_file|
|
12
|
+
temp_file.tap { |f| f.write(string) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'helpers/config_helper'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Enable flags like --only-failures and --next-failure
|
8
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
9
|
+
|
10
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
11
|
+
config.disable_monkey_patching!
|
12
|
+
|
13
|
+
config.expect_with :rspec do |c|
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
16
|
+
|
17
|
+
config.include(Fusuma::ConfigHelper)
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fusuma-plugin-keypress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iberianpig
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fusuma
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
description: fusuma-plugin-keypress is Fusuma plugin for keypress combination.
|
28
28
|
email:
|
29
29
|
- yhkyky@gmail.com
|
@@ -31,19 +31,11 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- ".gitignore"
|
35
|
-
- ".rubocop.yml"
|
36
|
-
- ".travis.yml"
|
37
|
-
- CHANGELOG.md
|
38
|
-
- CODE_OF_CONDUCT.md
|
39
|
-
- Gemfile
|
40
34
|
- LICENSE.txt
|
41
35
|
- README.md
|
42
|
-
- Rakefile
|
43
36
|
- bin/console
|
44
37
|
- bin/setup
|
45
38
|
- fusuma-plugin-keypress.gemspec
|
46
|
-
- lefthook.yml
|
47
39
|
- lib/fusuma/plugin/buffers/keypress_buffer.rb
|
48
40
|
- lib/fusuma/plugin/detectors/keypress_detector.rb
|
49
41
|
- lib/fusuma/plugin/events/records/keypress_record.rb
|
@@ -51,11 +43,17 @@ files:
|
|
51
43
|
- lib/fusuma/plugin/keypress.rb
|
52
44
|
- lib/fusuma/plugin/keypress/version.rb
|
53
45
|
- lib/fusuma/plugin/parsers/keypress_parser.rb
|
46
|
+
- spec/fusuma/plugin/detectors/keypress_detector_spec.rb
|
47
|
+
- spec/fusuma/plugin/filters/keypress_filter_spec.rb
|
48
|
+
- spec/fusuma/plugin/keypress_spec.rb
|
49
|
+
- spec/helpers/config_helper.rb
|
50
|
+
- spec/spec_helper.rb
|
54
51
|
homepage: https://github.com/iberianpig/fusuma-plugin-keypress
|
55
52
|
licenses:
|
56
53
|
- MIT
|
57
|
-
metadata:
|
58
|
-
|
54
|
+
metadata:
|
55
|
+
rubygems_mfa_required: 'true'
|
56
|
+
post_install_message:
|
59
57
|
rdoc_options: []
|
60
58
|
require_paths:
|
61
59
|
- lib
|
@@ -63,15 +61,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
61
|
requirements:
|
64
62
|
- - ">="
|
65
63
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
64
|
+
version: 2.5.1
|
67
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
66
|
requirements:
|
69
|
-
- - "
|
67
|
+
- - ">="
|
70
68
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
69
|
+
version: '0'
|
72
70
|
requirements: []
|
73
|
-
rubygems_version: 3.1
|
74
|
-
signing_key:
|
71
|
+
rubygems_version: 3.0.3.1
|
72
|
+
signing_key:
|
75
73
|
specification_version: 4
|
76
74
|
summary: Keypress plugin for Fusuma
|
77
|
-
test_files:
|
75
|
+
test_files:
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
- spec/helpers/config_helper.rb
|
78
|
+
- spec/fusuma/plugin/filters/keypress_filter_spec.rb
|
79
|
+
- spec/fusuma/plugin/keypress_spec.rb
|
80
|
+
- spec/fusuma/plugin/detectors/keypress_detector_spec.rb
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.4
|
3
|
-
NewCops: enable
|
4
|
-
|
5
|
-
Metrics/ModuleLength:
|
6
|
-
Exclude:
|
7
|
-
- "**/*_spec.rb"
|
8
|
-
|
9
|
-
Metrics/BlockLength:
|
10
|
-
Exclude:
|
11
|
-
- "**/*_spec.rb"
|
12
|
-
- "fusuma-plugin-*.gemspec"
|
13
|
-
|
14
|
-
Metrics/LineLength:
|
15
|
-
Max: 100
|
16
|
-
Exclude:
|
17
|
-
- "fusuma-plugin-*.gemspec"
|
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## [v0.4.0.pre](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.4.0.pre) (2020-11-09)
|
4
|
-
|
5
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.3.0...v0.4.0.pre)
|
6
|
-
|
7
|
-
## [v0.3.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.3.0) (2020-11-09)
|
8
|
-
|
9
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.2.1...v0.3.0)
|
10
|
-
|
11
|
-
## [v0.2.1](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.2.1) (2020-04-15)
|
12
|
-
|
13
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.2.0...v0.2.1)
|
14
|
-
|
15
|
-
**Closed issues:**
|
16
|
-
|
17
|
-
- Only 'LEFTMETA' keycode works on KDE Plasma [\#2](https://github.com/iberianpig/fusuma-plugin-keypress/issues/2)
|
18
|
-
|
19
|
-
## [v0.2.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.2.0) (2020-03-18)
|
20
|
-
|
21
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.1...v0.2.0)
|
22
|
-
|
23
|
-
**Closed issues:**
|
24
|
-
|
25
|
-
- Trigger a command multiple times while keeping the key pressed [\#1](https://github.com/iberianpig/fusuma-plugin-keypress/issues/1)
|
26
|
-
|
27
|
-
## [v0.1.1](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.1) (2020-02-18)
|
28
|
-
|
29
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.0...v0.1.1)
|
30
|
-
|
31
|
-
## [v0.1.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.0) (2019-11-12)
|
32
|
-
|
33
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/fb8d8ccfc3828e487607706335f670ae5392f08d...v0.1.0)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at yhkyky@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in fusuma-plugin-keypress.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'bundler'
|
9
|
-
gem 'github_changelog_generator'
|
10
|
-
gem 'lefthook'
|
11
|
-
gem 'pry-byebug', '~> 3.4'
|
12
|
-
gem 'pry-doc'
|
13
|
-
gem 'pry-inline'
|
14
|
-
gem 'rake', '~> 13.0'
|
15
|
-
gem 'reek'
|
16
|
-
gem 'rspec', '~> 3.0'
|
17
|
-
gem 'rubocop'
|
18
|
-
gem 'yard'
|
data/Rakefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
task default: :spec
|
9
|
-
|
10
|
-
require 'github_changelog_generator/task'
|
11
|
-
|
12
|
-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
13
|
-
config.user = 'iberianpig'
|
14
|
-
config.project = 'fusuma-plugin-keypress'
|
15
|
-
end
|
data/lefthook.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# EXAMPLE USAGE
|
2
|
-
# Refer for explanation to following link:
|
3
|
-
# https://github.com/Arkweid/lefthook/blob/master/docs/full_guide.md
|
4
|
-
|
5
|
-
# pre-push:
|
6
|
-
# commands:
|
7
|
-
# packages-audit:
|
8
|
-
# tags: frontend security
|
9
|
-
# run: yarn audit
|
10
|
-
# gems-audit:
|
11
|
-
# tags: backend security
|
12
|
-
# run: bundle audit
|
13
|
-
|
14
|
-
pre-commit:
|
15
|
-
parallel: true
|
16
|
-
commands:
|
17
|
-
# eslint:
|
18
|
-
# glob: "*.{js,ts}"
|
19
|
-
# run: yarn eslint {staged_files}
|
20
|
-
rubocop:
|
21
|
-
tags: backend style
|
22
|
-
glob: "*.rb"
|
23
|
-
# exclude: "application.rb|routes.rb"
|
24
|
-
run: bundle exec rubocop --force-exclusion {staged_files}
|
25
|
-
# scripts:
|
26
|
-
# "hello.js":
|
27
|
-
# runner: node
|
28
|
-
# "any.go":
|
29
|
-
# runner: go run
|