boaw 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/boaw/version.rb +1 -1
- data/lib/boaw.rb +14 -2
- data/lib/xdotool/adapter.rb +35 -0
- 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: b7888bcff81bb35a03e6c4e756fa14fbdf8bb4afdc09955aa769d4267776c41c
|
4
|
+
data.tar.gz: 9abf00d8b7287c7dc0b68a3658ad1a2ca36294c0fc7e69680c70b5a1d37e927f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5586887d3fc18a6b5d14db1a379fb3e34821a65f0bf8fcede9aaab182801ee093b50bb5c7d7d0f008954b9e2739d1961f6ab42de5ee35c172bd16c522319710a
|
7
|
+
data.tar.gz: c7c470bc142556f9022061d4f8592a2781e40050f375538a4647cba610e2cc6088a5ea117aee832de4bf3eb82060f659676494cdfce101bf67543d74fba8d6a3
|
data/lib/boaw/version.rb
CHANGED
data/lib/boaw.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'xdotool/adapter'
|
4
|
+
|
3
5
|
# Main class
|
4
6
|
class Boaw
|
5
|
-
|
6
|
-
|
7
|
+
attr_reader :adapter
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@adapter = Xdotool::Adapter.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def position
|
14
|
+
adapter.position
|
15
|
+
end
|
16
|
+
|
17
|
+
def left_click(position)
|
18
|
+
adapter.left_click(position)
|
7
19
|
end
|
8
20
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Xdotool
|
4
|
+
# Xdotool adapter for mouse control
|
5
|
+
class Adapter
|
6
|
+
def position
|
7
|
+
system('xdotool getmouselocation>temp.txt')
|
8
|
+
|
9
|
+
current_position = parse_position
|
10
|
+
|
11
|
+
{
|
12
|
+
x: current_position['x'].to_i,
|
13
|
+
y: current_position['y'].to_i
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def left_click(position)
|
18
|
+
system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def parse_position
|
24
|
+
file = File.open('./temp.txt', 'r')
|
25
|
+
position = file.gets.scan(/(\w+):(\d+)/).to_h
|
26
|
+
file.close
|
27
|
+
delete_temp_file
|
28
|
+
position
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete_temp_file
|
32
|
+
File.delete('./temp.txt')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boaw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Leonov
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/boaw.rb
|
20
20
|
- lib/boaw/version.rb
|
21
|
+
- lib/xdotool/adapter.rb
|
21
22
|
homepage: https://github.com/leonovk/boaw
|
22
23
|
licenses:
|
23
24
|
- MIT
|