rubydotool 0.1.1 → 0.1.2
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 +7 -2
- data/lib/rubydotool/keycodes.json +144 -0
- data/lib/rubydotool/version.rb +1 -1
- data/lib/rubydotool.rb +21 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 921b436a189e39b1e9f577fe9c4f6115445ecb7482e760c01fc657f5a755f0dc
|
|
4
|
+
data.tar.gz: f4628bed36de63e0d3bad570ea40250772cd3ca0dfec83d41fe74551ee10f574
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed7fb417b85c39ac8eb50f97118ed914b47048a46be49acf85596877f74e43ef8ee9aac3c6290f1c663eecedd0df55286beab2ead02e8a297f2dc26472176170
|
|
7
|
+
data.tar.gz: 327156687cc4d9cf4fc238e64b50d8d19ddbe70e0981ecb93ad6fca4f93259c66dd6d0dbda5c2e106e3c8fd0c8fa5f22d64ce4171d62cd3fb5e36068f2b7dea0
|
data/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A small Ruby wrapper for `ydotool`.
|
|
4
4
|
|
|
5
|
+
```bash
|
|
6
|
+
gem install rubydotool
|
|
7
|
+
```
|
|
8
|
+
|
|
5
9
|
Install `ydotool` with your system package manager, then add the gem:
|
|
6
10
|
|
|
7
11
|
```ruby
|
|
@@ -12,7 +16,8 @@ gem "rubydotool"
|
|
|
12
16
|
require "rubydotool"
|
|
13
17
|
|
|
14
18
|
Rubydotool.type("Hello from Ruby")
|
|
15
|
-
Rubydotool.key(
|
|
19
|
+
Rubydotool.key(:enter)
|
|
20
|
+
Rubydotool.hotkey(:ctrl, :alt, :t)
|
|
16
21
|
Rubydotool.click
|
|
17
22
|
Rubydotool.right_click
|
|
18
23
|
Rubydotool.move(50, -20)
|
|
@@ -21,4 +26,4 @@ Rubydotool.move_to(800, 450)
|
|
|
21
26
|
|
|
22
27
|
The daemon starts on the first command and stops when the Ruby process exits. `Rubydotool.start` and `Rubydotool.stop` are also available.
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
The process needs permission to access `/dev/uinput`.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"escape": 1,
|
|
3
|
+
"1": 2,
|
|
4
|
+
"2": 3,
|
|
5
|
+
"3": 4,
|
|
6
|
+
"4": 5,
|
|
7
|
+
"5": 6,
|
|
8
|
+
"6": 7,
|
|
9
|
+
"7": 8,
|
|
10
|
+
"8": 9,
|
|
11
|
+
"9": 10,
|
|
12
|
+
"0": 11,
|
|
13
|
+
"minus": 12,
|
|
14
|
+
"equal": 13,
|
|
15
|
+
"backspace": 14,
|
|
16
|
+
"tab": 15,
|
|
17
|
+
"q": 16,
|
|
18
|
+
"w": 17,
|
|
19
|
+
"e": 18,
|
|
20
|
+
"r": 19,
|
|
21
|
+
"t": 20,
|
|
22
|
+
"y": 21,
|
|
23
|
+
"u": 22,
|
|
24
|
+
"i": 23,
|
|
25
|
+
"o": 24,
|
|
26
|
+
"p": 25,
|
|
27
|
+
"left_bracket": 26,
|
|
28
|
+
"right_bracket": 27,
|
|
29
|
+
"enter": 28,
|
|
30
|
+
"ctrl": 29,
|
|
31
|
+
"left_ctrl": 29,
|
|
32
|
+
"a": 30,
|
|
33
|
+
"s": 31,
|
|
34
|
+
"d": 32,
|
|
35
|
+
"f": 33,
|
|
36
|
+
"g": 34,
|
|
37
|
+
"h": 35,
|
|
38
|
+
"j": 36,
|
|
39
|
+
"k": 37,
|
|
40
|
+
"l": 38,
|
|
41
|
+
"semicolon": 39,
|
|
42
|
+
"apostrophe": 40,
|
|
43
|
+
"grave": 41,
|
|
44
|
+
"shift": 42,
|
|
45
|
+
"left_shift": 42,
|
|
46
|
+
"backslash": 43,
|
|
47
|
+
"z": 44,
|
|
48
|
+
"x": 45,
|
|
49
|
+
"c": 46,
|
|
50
|
+
"v": 47,
|
|
51
|
+
"b": 48,
|
|
52
|
+
"n": 49,
|
|
53
|
+
"m": 50,
|
|
54
|
+
"comma": 51,
|
|
55
|
+
"period": 52,
|
|
56
|
+
"slash": 53,
|
|
57
|
+
"right_shift": 54,
|
|
58
|
+
"numpad_multiply": 55,
|
|
59
|
+
"alt": 56,
|
|
60
|
+
"left_alt": 56,
|
|
61
|
+
"space": 57,
|
|
62
|
+
"caps_lock": 58,
|
|
63
|
+
"f1": 59,
|
|
64
|
+
"f2": 60,
|
|
65
|
+
"f3": 61,
|
|
66
|
+
"f4": 62,
|
|
67
|
+
"f5": 63,
|
|
68
|
+
"f6": 64,
|
|
69
|
+
"f7": 65,
|
|
70
|
+
"f8": 66,
|
|
71
|
+
"f9": 67,
|
|
72
|
+
"f10": 68,
|
|
73
|
+
"num_lock": 69,
|
|
74
|
+
"scroll_lock": 70,
|
|
75
|
+
"numpad_7": 71,
|
|
76
|
+
"numpad_8": 72,
|
|
77
|
+
"numpad_9": 73,
|
|
78
|
+
"numpad_minus": 74,
|
|
79
|
+
"numpad_4": 75,
|
|
80
|
+
"numpad_5": 76,
|
|
81
|
+
"numpad_6": 77,
|
|
82
|
+
"numpad_plus": 78,
|
|
83
|
+
"numpad_1": 79,
|
|
84
|
+
"numpad_2": 80,
|
|
85
|
+
"numpad_3": 81,
|
|
86
|
+
"numpad_0": 82,
|
|
87
|
+
"numpad_period": 83,
|
|
88
|
+
"f11": 87,
|
|
89
|
+
"f12": 88,
|
|
90
|
+
"numpad_enter": 96,
|
|
91
|
+
"right_ctrl": 97,
|
|
92
|
+
"numpad_slash": 98,
|
|
93
|
+
"print_screen": 99,
|
|
94
|
+
"right_alt": 100,
|
|
95
|
+
"home": 102,
|
|
96
|
+
"up": 103,
|
|
97
|
+
"page_up": 104,
|
|
98
|
+
"left": 105,
|
|
99
|
+
"right": 106,
|
|
100
|
+
"end": 107,
|
|
101
|
+
"down": 108,
|
|
102
|
+
"page_down": 109,
|
|
103
|
+
"insert": 110,
|
|
104
|
+
"delete": 111,
|
|
105
|
+
"mute": 113,
|
|
106
|
+
"volume_down": 114,
|
|
107
|
+
"volume_up": 115,
|
|
108
|
+
"power": 116,
|
|
109
|
+
"pause": 119,
|
|
110
|
+
"super": 125,
|
|
111
|
+
"meta": 125,
|
|
112
|
+
"left_super": 125,
|
|
113
|
+
"right_super": 126,
|
|
114
|
+
"compose": 127,
|
|
115
|
+
"menu": 139,
|
|
116
|
+
"calculator": 140,
|
|
117
|
+
"sleep": 142,
|
|
118
|
+
"wake_up": 143,
|
|
119
|
+
"browser": 150,
|
|
120
|
+
"mail": 155,
|
|
121
|
+
"browser_back": 158,
|
|
122
|
+
"browser_forward": 159,
|
|
123
|
+
"next_track": 163,
|
|
124
|
+
"play_pause": 164,
|
|
125
|
+
"previous_track": 165,
|
|
126
|
+
"stop": 166,
|
|
127
|
+
"browser_refresh": 173,
|
|
128
|
+
"f13": 183,
|
|
129
|
+
"f14": 184,
|
|
130
|
+
"f15": 185,
|
|
131
|
+
"f16": 186,
|
|
132
|
+
"f17": 187,
|
|
133
|
+
"f18": 188,
|
|
134
|
+
"f19": 189,
|
|
135
|
+
"f20": 190,
|
|
136
|
+
"f21": 191,
|
|
137
|
+
"f22": 192,
|
|
138
|
+
"f23": 193,
|
|
139
|
+
"f24": 194,
|
|
140
|
+
"print": 210,
|
|
141
|
+
"search": 217,
|
|
142
|
+
"brightness_down": 224,
|
|
143
|
+
"brightness_up": 225
|
|
144
|
+
}
|
data/lib/rubydotool/version.rb
CHANGED
data/lib/rubydotool.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
require "json"
|
|
1
2
|
require_relative "rubydotool/version"
|
|
2
3
|
|
|
3
4
|
module Rubydotool
|
|
4
5
|
SOCKET = "/tmp/rubydotool-#{Process.pid}.sock"
|
|
6
|
+
KEYCODES_FILE = File.join(__dir__, "rubydotool", "keycodes.json")
|
|
7
|
+
KEYCODES = JSON.parse(File.read(KEYCODES_FILE))
|
|
5
8
|
|
|
6
9
|
@pid = nil
|
|
7
10
|
|
|
@@ -65,11 +68,13 @@ module Rubydotool
|
|
|
65
68
|
def self.key(*keycodes)
|
|
66
69
|
events = []
|
|
67
70
|
|
|
68
|
-
keycodes.each do |
|
|
71
|
+
keycodes.each do |key|
|
|
72
|
+
keycode = find_keycode(key)
|
|
69
73
|
events << "#{keycode}:1"
|
|
70
74
|
end
|
|
71
75
|
|
|
72
|
-
keycodes.reverse.each do |
|
|
76
|
+
keycodes.reverse.each do |key|
|
|
77
|
+
keycode = find_keycode(key)
|
|
73
78
|
events << "#{keycode}:0"
|
|
74
79
|
end
|
|
75
80
|
|
|
@@ -95,6 +100,20 @@ module Rubydotool
|
|
|
95
100
|
def self.move_to(x, y)
|
|
96
101
|
run("mousemove", "--absolute", x, y)
|
|
97
102
|
end
|
|
103
|
+
|
|
104
|
+
def self.find_keycode(key)
|
|
105
|
+
if key.is_a?(Integer)
|
|
106
|
+
return key
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
keycode = KEYCODES[key.to_s]
|
|
110
|
+
|
|
111
|
+
if keycode.nil?
|
|
112
|
+
raise "unknown key: #{key}"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
keycode
|
|
116
|
+
end
|
|
98
117
|
end
|
|
99
118
|
|
|
100
119
|
at_exit do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubydotool
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gavff
|
|
@@ -17,6 +17,7 @@ files:
|
|
|
17
17
|
- LICENSE
|
|
18
18
|
- README.md
|
|
19
19
|
- lib/rubydotool.rb
|
|
20
|
+
- lib/rubydotool/keycodes.json
|
|
20
21
|
- lib/rubydotool/version.rb
|
|
21
22
|
homepage: https://github.com/gavff64/rubydotool
|
|
22
23
|
licenses:
|