fusuma-plugin-sendkey 0.10.0 → 0.11.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 +32 -23
- data/exe/fusuma-sendkey +15 -3
- data/fusuma-plugin-sendkey.gemspec +1 -1
- data/lib/fusuma/plugin/executors/sendkey_executor.rb +16 -7
- data/lib/fusuma/plugin/sendkey/keyboard.rb +29 -8
- data/lib/fusuma/plugin/sendkey/version.rb +1 -1
- data/lib/fusuma/plugin/sendkey.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e094c69745660103650d6670883009eceaa0a879e724319997bbfed547d893c
|
4
|
+
data.tar.gz: 627342211f6fd7b333c255264f62766ee2324fbafe3e4682005f9ac10fbfd948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa5c2bb43f7807f07d474f596ac57744cd1ae290a688378b4cee60c3604c52a459dad74c2cd46ec7a014b9fdda521723f1f943094d6df1e1d9959ea503089336
|
7
|
+
data.tar.gz: 86314f9c58db0247a5d1621b8d7220546403de38121029209ea158e37a0c805a5355f1f2b80dbb3adef5749916d25c963181b824d2a58d7c80611df1d6925629
|
data/README.md
CHANGED
@@ -38,12 +38,12 @@ $ sudo gem install bundler
|
|
38
38
|
$ sudo gem install fusuma-plugin-sendkey
|
39
39
|
```
|
40
40
|
|
41
|
-
## List
|
41
|
+
## List Available Keys
|
42
42
|
|
43
43
|
```sh
|
44
44
|
$ fusuma-sendkey -l
|
45
45
|
```
|
46
|
-
|
46
|
+
To look up a specific key, such as the next or previous song, you can use the `grep -i` filter.
|
47
47
|
|
48
48
|
```sh
|
49
49
|
$ fusuma-sendkey -l | grep -i song
|
@@ -51,38 +51,50 @@ NEXTSONG
|
|
51
51
|
PREVIOUSSONG
|
52
52
|
```
|
53
53
|
|
54
|
-
##
|
54
|
+
## Running fusuma-sendkey on Terminal
|
55
55
|
|
56
|
-
* `fusuma-sendkey` command is available on your terminal
|
56
|
+
* `fusuma-sendkey` command is available on your terminal for testing.
|
57
57
|
* `fusuma-sendkey` supports modifier keys and multiple key presses.
|
58
|
-
Combine keys for pressing the same time with `+`
|
58
|
+
- Combine keys for pressing the same time with `+`
|
59
|
+
- Separate keys for pressing sequentially with `,`
|
59
60
|
|
61
|
+
### Example (Sendkey with Modifier Keys)
|
60
62
|
|
61
63
|
```sh
|
62
|
-
$ fusuma-sendkey LEFTCTRL+T #
|
64
|
+
$ fusuma-sendkey LEFTCTRL+T # Open a new tab
|
65
|
+
```
|
66
|
+
|
67
|
+
### Example (Sendkey with Multiple Key Presses)
|
68
|
+
|
69
|
+
```sh
|
70
|
+
$ fusuma-sendkey ["LEFTSHIFT+F10", "T", "ENTER", "ESC"] # Google Translate
|
63
71
|
```
|
64
72
|
|
65
73
|
Some of the keys found with `fusuma-sendkey -l` may actually be invalid keys.
|
66
|
-
So test
|
74
|
+
So test them first with `fusuma-sendkey <KEYCODE>` before adding them to config.yml.
|
67
75
|
|
68
76
|
|
69
|
-
## Add
|
77
|
+
## Add Sendkey Properties to config.yml
|
70
78
|
|
71
|
-
Add `sendkey:` property in `~/.config/fusuma/config.yml`.
|
79
|
+
Add the `sendkey:` property in your `~/.config/fusuma/config.yml`.
|
72
80
|
|
73
|
-
|
81
|
+
Lines beginning with `#` are comments.
|
74
82
|
|
75
83
|
```yaml
|
76
84
|
swipe:
|
77
85
|
3:
|
78
86
|
left:
|
79
|
-
sendkey: "LEFTALT+RIGHT" #
|
87
|
+
sendkey: "LEFTALT+RIGHT" # History back
|
80
88
|
right:
|
81
|
-
sendkey: "LEFTALT+LEFT" #
|
89
|
+
sendkey: "LEFTALT+LEFT" # History forward
|
82
90
|
up:
|
83
|
-
sendkey: "LEFTCTRL+T" #
|
91
|
+
sendkey: "LEFTCTRL+T" # Open a new tab
|
84
92
|
down:
|
85
|
-
sendkey: "LEFTCTRL+W" #
|
93
|
+
sendkey: "LEFTCTRL+W" # Close a tab
|
94
|
+
|
95
|
+
hold:
|
96
|
+
3:
|
97
|
+
sendkey: ["LEFTSHIFT+F10", "T", "ENTER", "ESC"] # Translate in Google Chrome
|
86
98
|
```
|
87
99
|
|
88
100
|
### clearmodifiers
|
@@ -96,21 +108,19 @@ swipe:
|
|
96
108
|
keypress:
|
97
109
|
LEFTSHIFT:
|
98
110
|
sendkey: "LEFTMETA+DOWN"
|
99
|
-
clearmodifiers: true #
|
111
|
+
clearmodifiers: true # Clear LEFTSHIFT before sending LEFTMETA+DOWN
|
100
112
|
```
|
101
113
|
|
114
|
+
### Specify Keyboard by Device Name
|
102
115
|
|
103
|
-
|
104
|
-
|
105
|
-
If you got following error message, try to set your keyboard name to `plugin.executors.sendkey_executor.device_name` on config.yml
|
116
|
+
If you encounter the following error message, please set your keyboard name in `plugin.executors.sendkey_executor.device_name` in config.yml.
|
106
117
|
|
107
|
-
```
|
118
|
+
```sh
|
108
119
|
$ fusuma-sendkey -l
|
109
120
|
sendkey: Keyboard: /keyboard|Keyboard|KEYBOARD/ is not found
|
110
121
|
```
|
111
122
|
|
112
|
-
|
113
|
-
Open `~/.config/fusuma/config.yml` and add the following code at the bottom.
|
123
|
+
Add the following code to the bottom of `~/.config/fusuma/config.yml` to recognize only the specified keyboard device.
|
114
124
|
|
115
125
|
```yaml
|
116
126
|
plugin:
|
@@ -119,8 +129,7 @@ plugin:
|
|
119
129
|
device_name: 'YOUR KEYBOARD NAME'
|
120
130
|
```
|
121
131
|
|
122
|
-
**If [fusuma-plugin-remap](https://github.com/iberianpig/fusuma-plugin-remap) is available, it will
|
123
|
-
|
132
|
+
**Note**: If [fusuma-plugin-remap](https://github.com/iberianpig/fusuma-plugin-remap) is available, it will automatically connect to `fusuma_virtual_keyboard`, so the `device_name` option is not required.
|
124
133
|
|
125
134
|
## Contributing
|
126
135
|
|
data/exe/fusuma-sendkey
CHANGED
@@ -36,13 +36,25 @@ if option[:version]
|
|
36
36
|
return
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
args = ARGV.first
|
40
40
|
|
41
|
-
if
|
41
|
+
if args.nil?
|
42
42
|
warn 'fusuma-sendkey require 1 arugument'
|
43
43
|
warn 'e.g. fusuma-sendkey LEFTALT+LEFT'
|
44
|
+
warn 'e.g. fusuma-sendkey [A, B, C]'
|
44
45
|
exit 1
|
45
46
|
end
|
46
47
|
|
48
|
+
|
49
|
+
# remove [ and ] from args
|
50
|
+
params = args.delete('[]').split(',').map(&:strip)
|
51
|
+
require 'debug'; debugger
|
52
|
+
|
47
53
|
keyboard = Fusuma::Plugin::Sendkey::Keyboard.new(name_pattern: device_name)
|
48
|
-
keyboard.valid?(
|
54
|
+
return unless keyboard.valid?(params)
|
55
|
+
|
56
|
+
if params.size == 1
|
57
|
+
keyboard.type(param: params.first)
|
58
|
+
else
|
59
|
+
keyboard.types(params)
|
60
|
+
end
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
# https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
26
26
|
# support focal (20.04LTS) 2.7
|
27
27
|
|
28
|
-
spec.add_dependency "fusuma", ">=
|
28
|
+
spec.add_dependency "fusuma", ">= 3.1"
|
29
29
|
spec.add_dependency "revdev"
|
30
30
|
end
|
@@ -26,12 +26,21 @@ module Fusuma
|
|
26
26
|
# @param event [Event]
|
27
27
|
# @return [nil]
|
28
28
|
def execute(event)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
params = search_param(event)
|
30
|
+
MultiLogger.info(sendkey: params)
|
31
|
+
case params
|
32
|
+
when Array
|
33
|
+
keyboard.types(params)
|
34
|
+
when String
|
35
|
+
keyboard.type(
|
36
|
+
param: params,
|
37
|
+
keep: search_keypress(event),
|
38
|
+
clear: clearmodifiers(event)
|
39
|
+
)
|
40
|
+
else
|
41
|
+
MultiLogger.error("sendkey: Invalid config: #{params}")
|
42
|
+
nil
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
46
|
# check executable
|
@@ -40,7 +49,7 @@ module Fusuma
|
|
40
49
|
def executable?(event)
|
41
50
|
event.tag.end_with?("_detector") &&
|
42
51
|
event.record.type == :index &&
|
43
|
-
keyboard.valid?(
|
52
|
+
keyboard.valid?(search_param(event))
|
44
53
|
end
|
45
54
|
|
46
55
|
private
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "revdev"
|
4
4
|
require "fusuma/device"
|
5
5
|
|
6
|
-
require_relative "
|
6
|
+
require_relative "device"
|
7
7
|
|
8
8
|
module Fusuma
|
9
9
|
module Plugin
|
@@ -27,7 +27,7 @@ module Fusuma
|
|
27
27
|
def self.find_device(name_pattern:)
|
28
28
|
Fusuma::Device.reset
|
29
29
|
Fusuma::Device.all.find { |d|
|
30
|
-
next unless d.capabilities
|
30
|
+
next unless /keyboard/.match?(d.capabilities)
|
31
31
|
|
32
32
|
d.name.match(/#{name_pattern}/)
|
33
33
|
}
|
@@ -45,9 +45,23 @@ module Fusuma
|
|
45
45
|
@device = Device.new(path: "/dev/input/#{device.id}")
|
46
46
|
end
|
47
47
|
|
48
|
+
# @param params [Array]
|
49
|
+
def types(args)
|
50
|
+
return unless args.is_a?(Array)
|
51
|
+
|
52
|
+
args.each do |arg|
|
53
|
+
case arg
|
54
|
+
when String
|
55
|
+
type(param: arg)
|
56
|
+
when Hash
|
57
|
+
type(**arg)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
48
62
|
# @param param [String] key names separated by '+' to type
|
49
63
|
# @param keep [String] key names separated by '+' to keep
|
50
|
-
# @param clear [String, Symbol, TrueClass] key names separated by '+' to clear or :all to
|
64
|
+
# @param clear [String, Symbol, TrueClass] key names separated by '+' to clear or :all to release all modifiers
|
51
65
|
def type(param:, keep: "", clear: :none)
|
52
66
|
return unless param.is_a?(String)
|
53
67
|
|
@@ -80,11 +94,18 @@ module Fusuma
|
|
80
94
|
end
|
81
95
|
|
82
96
|
# @param param [String]
|
83
|
-
def valid?(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
def valid?(params)
|
98
|
+
case params
|
99
|
+
when Array
|
100
|
+
params.all? { |param| valid?(param) }
|
101
|
+
when String
|
102
|
+
param = params
|
103
|
+
keycodes = param_to_keycodes(param)
|
104
|
+
keycodes.all? { |keycode| support?(keycode) }
|
105
|
+
else
|
106
|
+
MultiLogger.error "sendkey: Invalid config: #{params}"
|
107
|
+
nil
|
108
|
+
end
|
88
109
|
end
|
89
110
|
|
90
111
|
def send_event(code:, press: true)
|
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.11.0
|
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: 2024-08-30 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: '3.1'
|
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: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: revdev
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.4.
|
80
|
+
rubygems_version: 3.4.19
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Fusuma plugin to send keyboard events
|