fusuma-plugin-sendkey 0.10.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44727a1c5bc946a741238fbe69dc69f7251de60f8d7d27b76c37c6785cfc1870
4
- data.tar.gz: 8da2b282e60c73ecd4db5e9907ee41b9e2e3ae64a04e0cee96fa36583f593c8a
3
+ metadata.gz: 9e094c69745660103650d6670883009eceaa0a879e724319997bbfed547d893c
4
+ data.tar.gz: 627342211f6fd7b333c255264f62766ee2324fbafe3e4682005f9ac10fbfd948
5
5
  SHA512:
6
- metadata.gz: d880dcfa24cb1545aba87ef3af69a8139e907cba32145b84c4e3ff310a7d856f2bd8af536e9071887e3cbc77e72628365bf94700da109ce97f49ea7635e6ee15
7
- data.tar.gz: 9a9efda48ba1e7a566386905c216e1d4edc1d54b850331aeeaed6483045b2202cd6c21ee81d01fea59f74bee2a2b50883096091d809acdb32f7b8d050b80f82a
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 available keys
41
+ ## List Available Keys
42
42
 
43
43
  ```sh
44
44
  $ fusuma-sendkey -l
45
45
  ```
46
- If you want to look up a specific key, like the next song or the previous song, the `grep -i` refinement search is useful.
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
- ## Run fusuma-sendkey on Terminal
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 # press ctrl key + t key
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 it once with `fusuma-sendkey <KEYCODE>` and then add it to config.yml.
74
+ So test them first with `fusuma-sendkey <KEYCODE>` before adding them to config.yml.
67
75
 
68
76
 
69
- ## Add sendkey properties to config.yml
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
- lines beginning from `#` are comments
81
+ Lines beginning with `#` are comments.
74
82
 
75
83
  ```yaml
76
84
  swipe:
77
85
  3:
78
86
  left:
79
- sendkey: "LEFTALT+RIGHT" # history back
87
+ sendkey: "LEFTALT+RIGHT" # History back
80
88
  right:
81
- sendkey: "LEFTALT+LEFT" # history forward
89
+ sendkey: "LEFTALT+LEFT" # History forward
82
90
  up:
83
- sendkey: "LEFTCTRL+T" # open new tab
91
+ sendkey: "LEFTCTRL+T" # Open a new tab
84
92
  down:
85
- sendkey: "LEFTCTRL+W" # close tab
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 # clear LEFTSHIFT before sending LEFTMETA+DOWN
111
+ clearmodifiers: true # Clear LEFTSHIFT before sending LEFTMETA+DOWN
100
112
  ```
101
113
 
114
+ ### Specify Keyboard by Device Name
102
115
 
103
- ### Specify keyboard by device name
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
- ```shell
118
+ ```sh
108
119
  $ fusuma-sendkey -l
109
120
  sendkey: Keyboard: /keyboard|Keyboard|KEYBOARD/ is not found
110
121
  ```
111
122
 
112
- Set the following options to recognize keyboard only for the specified keyboard device.
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 be automatically connected to `fusuma_virtual_keyboard`, so `device_name` option is not required.**
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
- param = ARGV.first
39
+ args = ARGV.first
40
40
 
41
- if param.nil?
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?(param: param) && keyboard.type(param: param)
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
@@ -26,12 +26,21 @@ module Fusuma
26
26
  # @param event [Event]
27
27
  # @return [nil]
28
28
  def execute(event)
29
- MultiLogger.info(sendkey: search_param(event))
30
- keyboard.type(
31
- param: search_param(event),
32
- keep: search_keypress(event),
33
- clear: clearmodifiers(event)
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?(param: search_param(event))
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 "./device"
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.include? "keyboard"
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 relase all modifiers
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?(param:)
84
- return unless param.is_a?(String)
85
-
86
- keycodes = param_to_keycodes(param)
87
- keycodes.all? { |keycode| support?(keycode) }
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)
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Sendkey
6
- VERSION = "0.10.1"
6
+ VERSION = "0.11.0"
7
7
  end
8
8
  end
9
9
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # fusuma will `require fusuma-plugin-xxxx/plugin/xxxx.rb`
4
4
 
5
- require_relative "./sendkey/version"
6
- require_relative "./executors/sendkey_executor"
5
+ require_relative "sendkey/version"
6
+ require_relative "executors/sendkey_executor"
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.10.1
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: 2023-09-03 00:00:00.000000000 Z
11
+ date: 2024-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fusuma
@@ -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.10
80
+ rubygems_version: 3.4.19
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Fusuma plugin to send keyboard events