fusuma-plugin-sendkey 0.5.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -4
- data/exe/fusuma-sendkey +1 -0
- data/fusuma-plugin-sendkey.gemspec +5 -16
- data/lib/fusuma/plugin/executors/sendkey_executor.rb +18 -7
- data/lib/fusuma/plugin/sendkey/keyboard.rb +26 -15
- data/lib/fusuma/plugin/sendkey/version.rb +1 -1
- data/spec/fusuma/plugin/executors/sendkey_executor_spec.rb +138 -0
- data/spec/fusuma/plugin/sendkey/keyboard_spec.rb +199 -0
- data/spec/fusuma/plugin/sendkey_spec.rb +7 -0
- data/spec/helpers/config_helper.rb +16 -0
- data/spec/spec_helper.rb +18 -0
- metadata +17 -155
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.rubocop.yml +0 -20
- data/.travis.yml +0 -9
- data/CHANGELOG.md +0 -21
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -4
- data/Rakefile +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cf085cf00f878f5262bd4ef48d3e8ab49354bea02823c85c11e6edea79e9854
|
4
|
+
data.tar.gz: 718effb43a443bbb46852c851bf4716688a3e5bab413fa8a13ddda0f1cca1058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea348132422cb7bab174e93eccabcd6df2ab358e5d282b619bd380e1a50452bc9c17021e046881cb256f9cb7ea3b30b2c752ba60f7e9be8b5bbe263ed9af7f04
|
7
|
+
data.tar.gz: 2a0e4eed20e056eff6708a7ce67c7015fd16ab85626c4729321328baaf7d6e27b25cc6509263a5c98630d37b41bb8a7a2d3c4a2e47f6225cfdf1bd2982030b6b
|
data/README.md
CHANGED
@@ -9,20 +9,35 @@
|
|
9
9
|
|
10
10
|
Run the following code in your terminal.
|
11
11
|
|
12
|
-
### Install dependencies
|
12
|
+
### 1. Install dependencies
|
13
|
+
|
14
|
+
#### For Debian Based Distros (Ubuntu, Debian, Mint, Pop!_OS)
|
13
15
|
|
14
16
|
**NOTE: If you have installed ruby by apt, you must install ruby-dev.**
|
15
17
|
```sh
|
16
|
-
$ sudo apt-get install libevdev-dev ruby-dev
|
18
|
+
$ sudo apt-get install libevdev-dev ruby-dev build-essential
|
17
19
|
```
|
18
20
|
|
19
|
-
|
21
|
+
#### For Arch Based Distros (Manjaro, Arch)
|
22
|
+
|
23
|
+
```zsh
|
24
|
+
$ sudo pacman -S libevdev base-devel
|
25
|
+
```
|
26
|
+
|
27
|
+
### 2. Install fusuma-plugin-sendkey
|
28
|
+
|
29
|
+
|
30
|
+
**Note For Arch Based Distros:** By default in Arch Linux, when running ```gem```, gems are installed per-user (into ```~/.gem/ruby/```), instead of system-wide (into ```/usr/lib/ruby/gems/```). This is considered the best way to manage gems on Arch, because otherwise they might interfere with gems installed by Pacman. (From Arch Wiki)
|
31
|
+
|
32
|
+
To install gems system-wide, see any of the methods listed on [Arch Wiki](https://wiki.archlinux.org/index.php/ruby#Installing_gems_system-wide)
|
33
|
+
|
20
34
|
|
21
35
|
```sh
|
36
|
+
$ sudo gem install revdev
|
37
|
+
$ sudo gem install bundler
|
22
38
|
$ sudo gem install fusuma-plugin-sendkey
|
23
39
|
```
|
24
40
|
|
25
|
-
|
26
41
|
## List available keys
|
27
42
|
|
28
43
|
```sh
|
data/exe/fusuma-sendkey
CHANGED
@@ -16,25 +16,14 @@ 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']
|
24
|
+
spec.required_ruby_version = '>= 2.5.1' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
25
|
+
# support bionic (18.04LTS) 2.5.1
|
26
26
|
|
27
|
-
spec.add_dependency 'fusuma', '~>
|
27
|
+
spec.add_dependency 'fusuma', '~> 2.0.0'
|
28
28
|
spec.add_dependency 'revdev'
|
29
|
-
|
30
|
-
spec.add_development_dependency 'bundler'
|
31
|
-
spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
|
32
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
33
|
-
spec.add_development_dependency 'pry-doc'
|
34
|
-
spec.add_development_dependency 'pry-inline'
|
35
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
36
|
-
spec.add_development_dependency 'reek'
|
37
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
-
spec.add_development_dependency 'rubocop'
|
39
|
-
spec.add_development_dependency 'yard'
|
40
29
|
end
|
@@ -1,31 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../sendkey/keyboard
|
3
|
+
require_relative '../sendkey/keyboard'
|
4
4
|
|
5
5
|
module Fusuma
|
6
6
|
module Plugin
|
7
7
|
module Executors
|
8
8
|
# Control Window or Workspaces by executing wctrl
|
9
9
|
class SendkeyExecutor < Executor
|
10
|
+
def execute_keys
|
11
|
+
[:sendkey]
|
12
|
+
end
|
13
|
+
|
10
14
|
def config_param_types
|
11
15
|
{
|
12
|
-
|
16
|
+
device_name: String
|
13
17
|
}
|
14
18
|
end
|
15
19
|
|
16
|
-
# execute sendkey command
|
20
|
+
# fork and execute sendkey command
|
17
21
|
# @param event [Event]
|
18
22
|
# @return [nil]
|
19
23
|
def execute(event)
|
20
24
|
MultiLogger.info(sendkey: search_param(event))
|
21
25
|
pid = fork do
|
22
26
|
Process.daemon(true)
|
23
|
-
|
27
|
+
_execute(event)
|
24
28
|
end
|
25
29
|
|
26
30
|
Process.detach(pid)
|
27
31
|
end
|
28
32
|
|
33
|
+
# execute sendkey command
|
34
|
+
# @param event [Event]
|
35
|
+
# @return [nil]
|
36
|
+
def _execute(event)
|
37
|
+
keyboard.type(param: search_param(event))
|
38
|
+
end
|
39
|
+
|
29
40
|
# check executable
|
30
41
|
# @param event [Event]
|
31
42
|
# @return [TrueClass, FalseClass]
|
@@ -39,9 +50,9 @@ module Fusuma
|
|
39
50
|
|
40
51
|
def keyboard
|
41
52
|
@keyboard ||= begin
|
42
|
-
|
43
|
-
|
44
|
-
|
53
|
+
name_pattren = config_params(:device_name)
|
54
|
+
Sendkey::Keyboard.new(name_pattern: name_pattren)
|
55
|
+
end
|
45
56
|
end
|
46
57
|
|
47
58
|
def search_param(event)
|
@@ -3,16 +3,32 @@
|
|
3
3
|
require 'revdev'
|
4
4
|
require 'fusuma/device'
|
5
5
|
|
6
|
-
require_relative './device
|
6
|
+
require_relative './device'
|
7
7
|
|
8
8
|
module Fusuma
|
9
9
|
module Plugin
|
10
10
|
module Sendkey
|
11
11
|
# Emulate Keyboard
|
12
12
|
class Keyboard
|
13
|
+
MODIFIER_KEY_CODES = %w[
|
14
|
+
KEY_CAPSLOCK
|
15
|
+
KEY_LEFTALT
|
16
|
+
KEY_LEFTCTRL
|
17
|
+
KEY_LEFTMETA
|
18
|
+
KEY_LEFTSHIFT
|
19
|
+
KEY_RIGHTALT
|
20
|
+
KEY_RIGHTCTRL
|
21
|
+
KEY_RIGHTSHIFT
|
22
|
+
KEY_RIGHTMETA
|
23
|
+
].freeze
|
24
|
+
|
25
|
+
def self.find_device(name_pattern:)
|
26
|
+
Fusuma::Device.all.find { |d| d.name.match(/#{name_pattern}/) }
|
27
|
+
end
|
28
|
+
|
13
29
|
def initialize(name_pattern: nil)
|
14
30
|
name_pattern ||= 'keyboard|Keyboard|KEYBOARD'
|
15
|
-
device = find_device(name_pattern: name_pattern)
|
31
|
+
device = Keyboard.find_device(name_pattern: name_pattern)
|
16
32
|
|
17
33
|
if device.nil?
|
18
34
|
warn "sendkey: Keyboard: /#{name_pattern}/ is not found"
|
@@ -25,15 +41,15 @@ module Fusuma
|
|
25
41
|
attr_reader :device
|
26
42
|
|
27
43
|
# @param param [String]
|
44
|
+
# @param keep [String]
|
28
45
|
def type(param:)
|
29
46
|
return unless param.is_a?(String)
|
30
47
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
keycodes.each { |keycode| key_event(keycode: keycode, press: true) }
|
48
|
+
param_keycodes = split_param(param)
|
49
|
+
clear_modifiers(MODIFIER_KEY_CODES - param_keycodes)
|
50
|
+
param_keycodes.each { |keycode| key_event(keycode: keycode, press: true) }
|
35
51
|
key_sync(press: true)
|
36
|
-
|
52
|
+
param_keycodes.reverse.each { |keycode| key_event(keycode: keycode, press: false) }
|
37
53
|
key_sync(press: false)
|
38
54
|
end
|
39
55
|
|
@@ -99,18 +115,13 @@ module Fusuma
|
|
99
115
|
Object.const_get "LinuxInput::#{keycode}"
|
100
116
|
end
|
101
117
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
modifiers.each { |code| key_event(keycode: key_prefix(code), press: false) }
|
118
|
+
# @param [Array<String>] keycodes to be released
|
119
|
+
def clear_modifiers(keycodes)
|
120
|
+
keycodes.each { |code| key_event(keycode: code, press: false) }
|
106
121
|
end
|
107
122
|
|
108
123
|
private
|
109
124
|
|
110
|
-
def find_device(name_pattern:)
|
111
|
-
Fusuma::Device.all.find { |d| d.name.match(/#{name_pattern}/) }
|
112
|
-
end
|
113
|
-
|
114
125
|
def split_param(param)
|
115
126
|
param.split('+').map { |code| key_prefix(code) }
|
116
127
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require 'fusuma/plugin/executors/executor'
|
6
|
+
require 'fusuma/plugin/events/event'
|
7
|
+
require 'fusuma/plugin/events/records/index_record'
|
8
|
+
|
9
|
+
require './lib/fusuma/plugin/executors/sendkey_executor'
|
10
|
+
|
11
|
+
module Fusuma
|
12
|
+
module Plugin
|
13
|
+
module Executors
|
14
|
+
RSpec.describe SendkeyExecutor do
|
15
|
+
around do |example|
|
16
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
17
|
+
dummy:
|
18
|
+
1:
|
19
|
+
direction:
|
20
|
+
sendkey: KEY_CODE
|
21
|
+
|
22
|
+
plugin:
|
23
|
+
executors:
|
24
|
+
sendkey_executor:
|
25
|
+
device_name: dummy
|
26
|
+
CONFIG
|
27
|
+
|
28
|
+
example.run
|
29
|
+
|
30
|
+
Config.custom_path = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
before do
|
34
|
+
index = Config::Index.new([:dummy, 1, :direction])
|
35
|
+
record = Events::Records::IndexRecord.new(index: index)
|
36
|
+
@event = Events::Event.new(tag: 'dummy_detector', record: record)
|
37
|
+
@executor = described_class.new
|
38
|
+
|
39
|
+
@keyboard = instance_double(Sendkey::Keyboard)
|
40
|
+
|
41
|
+
allow(@executor).to receive(:keyboard).and_return @keyboard
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#execute' do
|
45
|
+
before do
|
46
|
+
allow(Process).to receive(:daemon).with(true)
|
47
|
+
allow(Process).to receive(:detach).with(anything)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'fork' do
|
51
|
+
expect(@executor).to receive(:fork).and_yield do |block_context|
|
52
|
+
expect(block_context).to receive(:_execute).with(@event)
|
53
|
+
end
|
54
|
+
|
55
|
+
@executor.execute(@event)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#_execute' do
|
60
|
+
it 'send KEY_CODE message to keybard' do
|
61
|
+
allow(@executor).to receive(:search_param).with(@event).and_return('KEY_CODE')
|
62
|
+
expect(@keyboard).to receive(:type).with(param: 'KEY_CODE')
|
63
|
+
@executor._execute(@event)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#executable?' do
|
68
|
+
before do
|
69
|
+
allow(@keyboard).to receive(:valid?).with(param: 'MODIFIER_CODE+KEY_CODE')
|
70
|
+
.and_return true
|
71
|
+
allow(@keyboard).to receive(:valid?).with(param: 'KEY_CODE')
|
72
|
+
.and_return true
|
73
|
+
allow(@keyboard).to receive(:valid?).with(param: 'INVALID_CODE')
|
74
|
+
.and_return false
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when given valid event tagged as xxxx_detector' do
|
78
|
+
it { expect(@executor).to be_executable(@event) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when given INVALID event tagged as invalid_tag' do
|
82
|
+
before do
|
83
|
+
@event.tag = 'invalid_tag'
|
84
|
+
end
|
85
|
+
|
86
|
+
it { expect(@executor).not_to be_executable(@event) }
|
87
|
+
end
|
88
|
+
|
89
|
+
context "when sendkey: 'MODIFIER_CODE+KEY_CODE'" do
|
90
|
+
around do |example|
|
91
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
92
|
+
dummy:
|
93
|
+
1:
|
94
|
+
direction:
|
95
|
+
sendkey: 'MODIFIER_CODE+KEY_CODE'
|
96
|
+
plugin:
|
97
|
+
executors:
|
98
|
+
sendkey_executor:
|
99
|
+
device_name: dummy
|
100
|
+
CONFIG
|
101
|
+
|
102
|
+
example.run
|
103
|
+
|
104
|
+
Config.custom_path = nil
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns true' do
|
108
|
+
expect(@executor).to be_executable(@event)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when sendkey: 'INVALID_CODE'" do
|
113
|
+
around do |example|
|
114
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
115
|
+
dummy:
|
116
|
+
1:
|
117
|
+
direction:
|
118
|
+
sendkey: 'INVALID_CODE'
|
119
|
+
plugin:
|
120
|
+
executors:
|
121
|
+
sendkey_executor:
|
122
|
+
device_name: dummy
|
123
|
+
CONFIG
|
124
|
+
|
125
|
+
example.run
|
126
|
+
|
127
|
+
Config.custom_path = nil
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'returns true' do
|
131
|
+
expect(@executor).not_to be_executable(@event)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require './lib/fusuma/plugin/sendkey/keyboard'
|
6
|
+
|
7
|
+
module Fusuma
|
8
|
+
module Plugin
|
9
|
+
module Sendkey
|
10
|
+
RSpec.describe Keyboard do
|
11
|
+
describe '#new' do
|
12
|
+
context 'when keyboard is found' do
|
13
|
+
before do
|
14
|
+
dummy_keyboard = Fusuma::Device.new(name: 'dummy keyboard')
|
15
|
+
allow(described_class)
|
16
|
+
.to receive(:find_device)
|
17
|
+
.and_return(dummy_keyboard)
|
18
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not raise error' do
|
22
|
+
expect { described_class.new }.not_to raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when keyboard is not found' do
|
27
|
+
before do
|
28
|
+
allow(described_class)
|
29
|
+
.to receive(:find_device)
|
30
|
+
.and_return(nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'does not raise error' do
|
34
|
+
expect { described_class.new }.to raise_error SystemExit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when detected device name is Keyboard (Capitarized)' do
|
39
|
+
before do
|
40
|
+
other_device = Fusuma::Device.new(name: 'Keyboard', id: 'dummy')
|
41
|
+
|
42
|
+
allow(described_class)
|
43
|
+
.to receive(:find_device)
|
44
|
+
.and_return(other_device)
|
45
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'does not raise error' do
|
49
|
+
expect { described_class.new }.not_to raise_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when detected device name is KEYBOARD (Upper case)' do
|
54
|
+
before do
|
55
|
+
other_device = Fusuma::Device.new(name: 'KEYBOARD', id: 'dummy')
|
56
|
+
allow(described_class)
|
57
|
+
.to receive(:find_device)
|
58
|
+
.and_return(other_device)
|
59
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'does not raise error' do
|
63
|
+
expect { described_class.new }.not_to raise_error
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with given name pattern' do
|
68
|
+
before do
|
69
|
+
specified_device = Fusuma::Device.new(
|
70
|
+
name: 'Awesome KEY/BOARD input device',
|
71
|
+
id: 'dummy'
|
72
|
+
)
|
73
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
74
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'does not raise error' do
|
78
|
+
expect { described_class.new(name_pattern: 'Awesome KEY/BOARD') }.not_to raise_error
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when name pattern (use default) is not given' do
|
83
|
+
subject { -> { described_class.new(name_pattern: nil) } }
|
84
|
+
|
85
|
+
before do
|
86
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when exist device named keyboard(lower-case)' do
|
90
|
+
before do
|
91
|
+
specified_device = Fusuma::Device.new(
|
92
|
+
name: 'keyboard',
|
93
|
+
id: 'dummy'
|
94
|
+
)
|
95
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
96
|
+
end
|
97
|
+
|
98
|
+
it { is_expected.not_to raise_error }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when exist device named Keyboard(Capital-case)' do
|
102
|
+
before do
|
103
|
+
specified_device = Fusuma::Device.new(
|
104
|
+
name: 'Keyboard',
|
105
|
+
id: 'dummy'
|
106
|
+
)
|
107
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
108
|
+
end
|
109
|
+
|
110
|
+
it { is_expected.not_to raise_error }
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when exist device named KEYBOARD(UPPER case)' do
|
114
|
+
before do
|
115
|
+
specified_device = Fusuma::Device.new(
|
116
|
+
name: 'KEYBOARD',
|
117
|
+
id: 'dummy'
|
118
|
+
)
|
119
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
120
|
+
end
|
121
|
+
|
122
|
+
it { is_expected.not_to raise_error }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when exist no device named keyboard|Keyboard|KEYBOARD' do
|
126
|
+
before do
|
127
|
+
specified_device = Fusuma::Device.new(
|
128
|
+
name: 'KEY-BOARD',
|
129
|
+
id: 'dummy'
|
130
|
+
)
|
131
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
132
|
+
end
|
133
|
+
|
134
|
+
it { is_expected.to raise_error(SystemExit) }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#type' do
|
140
|
+
before do
|
141
|
+
allow(described_class)
|
142
|
+
.to receive(:find_device)
|
143
|
+
.and_return(Fusuma::Device.new(name: 'dummy keyboard'))
|
144
|
+
|
145
|
+
@device = instance_double(Sendkey::Device)
|
146
|
+
allow(@device).to receive(:write_event).with(anything)
|
147
|
+
# allow(@device).to receive(:valid?).with(param: 'KEY_A')
|
148
|
+
|
149
|
+
allow(Sendkey::Device).to receive(:new).and_return(@device)
|
150
|
+
|
151
|
+
@keyboard = described_class.new
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'presses key KEY_A and release KEY_A' do
|
155
|
+
expect(@keyboard).to receive(:clear_modifiers).ordered
|
156
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: true).ordered
|
157
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: false).ordered
|
158
|
+
@keyboard.type(param: 'A')
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'with modifier keys' do
|
162
|
+
before do
|
163
|
+
@keys = 'LEFTSHIFT+A'
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'clear all modifier keys except parameter of sendkey' do
|
167
|
+
expect(@keyboard).to receive(:clear_modifiers).with(Keyboard::MODIFIER_KEY_CODES - ['KEY_LEFTSHIFT']).ordered
|
168
|
+
@keyboard.type(param: @keys)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'types (Shift)A' do
|
172
|
+
expect(@keyboard).to receive(:clear_modifiers).ordered
|
173
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_LEFTSHIFT', press: true).ordered
|
174
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: true).ordered
|
175
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: false).ordered
|
176
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_LEFTSHIFT', press: false).ordered
|
177
|
+
@keyboard.type(param: @keys)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'with multiple keys' do
|
182
|
+
before do
|
183
|
+
@keys = 'A+B'
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'types AB' do
|
187
|
+
expect(@keyboard).to receive(:clear_modifiers).ordered
|
188
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: true).ordered
|
189
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_B', press: true).ordered
|
190
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_B', press: false).ordered
|
191
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: false).ordered
|
192
|
+
@keyboard.type(param: @keys)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
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-sendkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iberianpig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-05 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:
|
19
|
+
version: 2.0.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:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: revdev
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,146 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: github_changelog_generator
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.14'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.14'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-byebug
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.4'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.4'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-doc
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry-inline
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '13.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '13.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: reek
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rspec
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '3.0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '3.0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: rubocop
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: yard
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
41
|
description: Fusuma::Plugin::Sendkey emulate keyboard events with evdev
|
182
42
|
email:
|
183
43
|
- yhkyky@gmail.com
|
@@ -186,16 +46,8 @@ executables:
|
|
186
46
|
extensions: []
|
187
47
|
extra_rdoc_files: []
|
188
48
|
files:
|
189
|
-
- ".gitignore"
|
190
|
-
- ".rspec"
|
191
|
-
- ".rubocop.yml"
|
192
|
-
- ".travis.yml"
|
193
|
-
- CHANGELOG.md
|
194
|
-
- CODE_OF_CONDUCT.md
|
195
|
-
- Gemfile
|
196
49
|
- LICENSE.txt
|
197
50
|
- README.md
|
198
|
-
- Rakefile
|
199
51
|
- bin/console
|
200
52
|
- bin/setup
|
201
53
|
- exe/fusuma-sendkey
|
@@ -205,6 +57,11 @@ files:
|
|
205
57
|
- lib/fusuma/plugin/sendkey/device.rb
|
206
58
|
- lib/fusuma/plugin/sendkey/keyboard.rb
|
207
59
|
- lib/fusuma/plugin/sendkey/version.rb
|
60
|
+
- spec/fusuma/plugin/executors/sendkey_executor_spec.rb
|
61
|
+
- spec/fusuma/plugin/sendkey/keyboard_spec.rb
|
62
|
+
- spec/fusuma/plugin/sendkey_spec.rb
|
63
|
+
- spec/helpers/config_helper.rb
|
64
|
+
- spec/spec_helper.rb
|
208
65
|
homepage: https://github.com/iberianpig/fusuma-plugin-sendkey
|
209
66
|
licenses:
|
210
67
|
- MIT
|
@@ -217,15 +74,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
74
|
requirements:
|
218
75
|
- - ">="
|
219
76
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
77
|
+
version: 2.5.1
|
221
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
79
|
requirements:
|
223
80
|
- - ">="
|
224
81
|
- !ruby/object:Gem::Version
|
225
82
|
version: '0'
|
226
83
|
requirements: []
|
227
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.1.4
|
228
85
|
signing_key:
|
229
86
|
specification_version: 4
|
230
87
|
summary: Fusuma plugin to send keyboard events
|
231
|
-
test_files:
|
88
|
+
test_files:
|
89
|
+
- spec/fusuma/plugin/sendkey_spec.rb
|
90
|
+
- spec/fusuma/plugin/sendkey/keyboard_spec.rb
|
91
|
+
- spec/fusuma/plugin/executors/sendkey_executor_spec.rb
|
92
|
+
- spec/helpers/config_helper.rb
|
93
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Metrics/ModuleLength:
|
2
|
-
Exclude:
|
3
|
-
- "**/*_spec.rb"
|
4
|
-
|
5
|
-
Metrics/BlockLength:
|
6
|
-
Exclude:
|
7
|
-
- "**/*_spec.rb"
|
8
|
-
- "fusuma-plugin-*.gemspec"
|
9
|
-
|
10
|
-
Metrics/LineLength:
|
11
|
-
Max: 100
|
12
|
-
Exclude:
|
13
|
-
- "fusuma-plugin-*.gemspec"
|
14
|
-
|
15
|
-
Style/HashEachMethods:
|
16
|
-
Enabled: true
|
17
|
-
Style/HashTransformKeys:
|
18
|
-
Enabled: true
|
19
|
-
Style/HashTransformValues:
|
20
|
-
Enabled: true
|
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## [Unreleased](https://github.com/iberianpig/fusuma-plugin-keypress/tree/HEAD)
|
4
|
-
|
5
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.1...HEAD)
|
6
|
-
|
7
|
-
**Closed issues:**
|
8
|
-
|
9
|
-
- Trigger a command multiple times while keeping the key pressed [\#1](https://github.com/iberianpig/fusuma-plugin-keypress/issues/1)
|
10
|
-
|
11
|
-
## [v0.1.1](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.1) (2020-02-18)
|
12
|
-
|
13
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.0...v0.1.1)
|
14
|
-
|
15
|
-
## [v0.1.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.0) (2019-11-12)
|
16
|
-
|
17
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/fb8d8ccfc3828e487607706335f670ae5392f08d...v0.1.0)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
\* *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
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
|