xosd 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -0
- data/LICENSE +21 -0
- data/README.md +172 -0
- data/lib/xosd/xosd.rb +126 -0
- data/lib/xosd/xosd_bindings.rb +84 -0
- data/lib/xosd.rb +1 -0
- data/spec/xosd_spec.rb +83 -0
- data/xosd.gemspec +22 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f07a214334ffe8a9a960731a5c37bfb49079d5d
|
4
|
+
data.tar.gz: 642fba3637f1960b6e7a29f2840e49ec48686f15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31603176ef270276dec710c1d770b45a9b8a9d4ed64233e0ef23f0849f97eea3c86cfabf7f029bc71983eeb2847e08ba38cf6e595fdfabf603aeb532900898dc
|
7
|
+
data.tar.gz: 1529f243ec028427cfdea09c3f53a4cfe23c3b6795988f9bbfbdebda25117b7c1e7abe946df03a7784649d03b081a54fcf2d12500f54b7059b9ee3b3af2a21b4
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
xosd (1.0.0)
|
5
|
+
ffi
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
ffi (1.9.23)
|
12
|
+
rspec (3.7.0)
|
13
|
+
rspec-core (~> 3.7.0)
|
14
|
+
rspec-expectations (~> 3.7.0)
|
15
|
+
rspec-mocks (~> 3.7.0)
|
16
|
+
rspec-core (3.7.1)
|
17
|
+
rspec-support (~> 3.7.0)
|
18
|
+
rspec-expectations (3.7.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.7.0)
|
21
|
+
rspec-mocks (3.7.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.7.0)
|
24
|
+
rspec-support (3.7.1)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
rspec
|
31
|
+
xosd!
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
1.16.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Yurie Nagorny
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
# xosd
|
2
|
+
Ruby wrapper for xosd - X on screen display library
|
3
|
+
|
4
|
+
## libxosd version
|
5
|
+
The gem was designed for libxosd version 2.2.14 but likely to work with other versions too.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Constructor
|
10
|
+
|
11
|
+
Instantiate an instance of XOSD:
|
12
|
+
|
13
|
+
```
|
14
|
+
require 'xosd'
|
15
|
+
|
16
|
+
xosd = XOSD.new
|
17
|
+
```
|
18
|
+
|
19
|
+
You may pass zero or more of the options to the constructor:
|
20
|
+
|
21
|
+
| Option | Description |
|
22
|
+
| --- | --- |
|
23
|
+
| lines | max number of lines in the on screen message |
|
24
|
+
| :position | one of :top, :middle, :bottom |
|
25
|
+
| :align | one of :left, :center, :right |
|
26
|
+
| :colour | string with message color |
|
27
|
+
| :font | string with font |
|
28
|
+
| :horizontal_offset | horizontal message offset |
|
29
|
+
| :vertical_offset | vertical message offset |
|
30
|
+
| :outline_offset | message outline offset |
|
31
|
+
| :outline_colour | message outline color |
|
32
|
+
| :shadow_offset | message shadow offset |
|
33
|
+
| :shadow_colour | message shadow color |
|
34
|
+
| :bar_length | length of the percentage or slider bar |
|
35
|
+
| :timeout | how long the message is displayed, seconds |
|
36
|
+
|
37
|
+
All of the options have the corresponding setter, e.g. you can either:
|
38
|
+
|
39
|
+
```
|
40
|
+
xosd = XOSD.new(timeout: 5)
|
41
|
+
```
|
42
|
+
|
43
|
+
or
|
44
|
+
|
45
|
+
```
|
46
|
+
xosd = XOSD.new
|
47
|
+
xosd.timeout = 5
|
48
|
+
```
|
49
|
+
|
50
|
+
Example:
|
51
|
+
|
52
|
+
```
|
53
|
+
xosd = XOSD.new(
|
54
|
+
position: :bottom,
|
55
|
+
align: :center,
|
56
|
+
vertical_offset: 100,
|
57
|
+
font: '-*-arial-*-*-*-*-*-320-*-*-*-*-*-*',
|
58
|
+
colour: 'black',
|
59
|
+
outline_colour: 'orange',
|
60
|
+
outline_offset: 1,
|
61
|
+
shadow_colour: 'white',
|
62
|
+
shadow_offset: 1,
|
63
|
+
timeout: 3
|
64
|
+
)
|
65
|
+
xosd.display_string 'A line to display on screen'
|
66
|
+
xosd.teardown
|
67
|
+
```
|
68
|
+
|
69
|
+
### Teardown
|
70
|
+
|
71
|
+
When done with displaying on screen messages, make sure to teardown the object by calling the teardown method:
|
72
|
+
|
73
|
+
```
|
74
|
+
xosd.teardown
|
75
|
+
```
|
76
|
+
|
77
|
+
If you don't do it, it will try to tear itself down during garbage collection, but you should not depend on it.
|
78
|
+
|
79
|
+
### Displaying a string
|
80
|
+
|
81
|
+
To display a string use display method:
|
82
|
+
|
83
|
+
```
|
84
|
+
xosd.display 'A message to display on screen'
|
85
|
+
|
86
|
+
```
|
87
|
+
|
88
|
+
You may use several lines:
|
89
|
+
|
90
|
+
```
|
91
|
+
xosd = XOSD.new(lines: 3)
|
92
|
+
xosd.display 'First line to display', line: 0
|
93
|
+
xosd.display 'Second line to display', line: 1
|
94
|
+
xosd.display 'Third line to display', line: 2
|
95
|
+
xosd.teardown
|
96
|
+
```
|
97
|
+
|
98
|
+
You may use #scroll_by to scroll the messages:
|
99
|
+
|
100
|
+
```
|
101
|
+
xosd.scroll_by 1
|
102
|
+
```
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
### Displaying a percentage bar
|
107
|
+
|
108
|
+
To display a bar similar to TV volume bar:
|
109
|
+
|
110
|
+
```
|
111
|
+
xosd = XOSD.new(bar_length: 100)
|
112
|
+
xosd.bar_length = 100 # same effect as above
|
113
|
+
xosd.display_bar 50
|
114
|
+
```
|
115
|
+
|
116
|
+
Use :bar_length constructor option or set bar_length later to define how long the bar will be.
|
117
|
+
|
118
|
+
### Displaying a slider
|
119
|
+
|
120
|
+
To display a slider similar to TV brightness control:
|
121
|
+
|
122
|
+
```
|
123
|
+
xosd.display_slider 50
|
124
|
+
```
|
125
|
+
|
126
|
+
Adjust slider length similar to how it is done for the percentage bar.
|
127
|
+
|
128
|
+
### On screen?
|
129
|
+
|
130
|
+
Call on_screen? method to find out if anything is being displayed on screen.
|
131
|
+
|
132
|
+
```
|
133
|
+
xosd.on_screen?
|
134
|
+
```
|
135
|
+
|
136
|
+
### Wait until message is gone
|
137
|
+
|
138
|
+
You may wait for the message to disappear using xosd_wait_until_no_display:
|
139
|
+
|
140
|
+
```
|
141
|
+
xosd.xosd_wait_until_no_display
|
142
|
+
```
|
143
|
+
|
144
|
+
### Hide and show
|
145
|
+
|
146
|
+
You may hide and show the last displayed message
|
147
|
+
|
148
|
+
```
|
149
|
+
xosd.dispaly 'A message'
|
150
|
+
xosd.hide
|
151
|
+
xosd.show
|
152
|
+
```
|
153
|
+
|
154
|
+
## Virtual machine for gem development
|
155
|
+
If you are interested in making changes to the gem, you may want to setup a virtual machine to assist with that.
|
156
|
+
|
157
|
+
* Install Virtual Box from https://www.virtualbox.org/
|
158
|
+
* Install Vagrant from https://www.vagrantup.com/
|
159
|
+
* Provision the virtual machine (it will be named xosd):
|
160
|
+
|
161
|
+
$ vagrant up
|
162
|
+
|
163
|
+
* Add ssh info of the virtual machine to the ssh config:
|
164
|
+
|
165
|
+
$ vagrant ssh-config >> ~/.ssh/config
|
166
|
+
|
167
|
+
* To open an ssh session with the virtual machine (the gem folder will be mounted under /vagrant):
|
168
|
+
|
169
|
+
$ ssh -X xosd
|
170
|
+
|
171
|
+
|
172
|
+
|
data/lib/xosd/xosd.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require_relative 'xosd_bindings'
|
2
|
+
|
3
|
+
class XOSD
|
4
|
+
|
5
|
+
class XOSDError < StandardError; end
|
6
|
+
|
7
|
+
def initialize(opts={})
|
8
|
+
@osd = XOSD_Bindings.xosd_create opts[:lines]||1
|
9
|
+
handle(-1) if @osd.null?
|
10
|
+
ObjectSpace.define_finalizer(self, self.class.method(:finalize).to_proc)
|
11
|
+
self.bar_length = opts[:bar_length] if opts[:bar_length]
|
12
|
+
self.position = opts[:position] if opts[:position]
|
13
|
+
self.align = opts[:align] if opts[:align]
|
14
|
+
self.colour = opts[:colour] if opts[:colour]
|
15
|
+
self.font = opts[:font] if opts[:font]
|
16
|
+
self.horizontal_offset = opts[:horizontal_offset] if opts[:horizontal_offset]
|
17
|
+
self.vertical_offset = opts[:vertical_offset] if opts[:vertical_offset]
|
18
|
+
self.outline_offset = opts[:outline_offset] if opts[:outline_offset]
|
19
|
+
self.outline_colour = opts[:outline_colour] if opts[:outline_colour]
|
20
|
+
self.shadow_offset = opts[:shadow_offset] if opts[:shadow_offset]
|
21
|
+
self.shadow_colour = opts[:shadow_colour] if opts[:shadow_colour]
|
22
|
+
self.timeout = opts[:timeout] if opts[:timeout]
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown
|
26
|
+
handle(XOSD_Bindings.xosd_destroy(@osd)) if @osd && !@osd.null?
|
27
|
+
@osd = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def display(string, opts={line: 0})
|
31
|
+
handle(XOSD_Bindings.xosd_display(@osd, opts[:line], :xosd_command, :string, :string, string))
|
32
|
+
end
|
33
|
+
|
34
|
+
def display_bar(percentage, opts={line: 0})
|
35
|
+
handle(XOSD_Bindings.xosd_display(@osd, opts[:line], :xosd_command, :percentage, :int, percentage))
|
36
|
+
end
|
37
|
+
|
38
|
+
def display_slider(percentage, opts={line: 0})
|
39
|
+
handle(XOSD_Bindings.xosd_display(@osd, opts[:line], :xosd_command, :slider, :int, percentage))
|
40
|
+
end
|
41
|
+
|
42
|
+
def on_screen?
|
43
|
+
XOSD_Bindings.xosd_is_onscreen(@osd) != 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def xosd_wait_until_no_display
|
47
|
+
handle(XOSD_Bindings.xosd_wait_until_no_display(@osd))
|
48
|
+
end
|
49
|
+
|
50
|
+
def hide
|
51
|
+
handle(XOSD_Bindings.xosd_hide(@osd))
|
52
|
+
end
|
53
|
+
|
54
|
+
def show
|
55
|
+
handle(XOSD_Bindings.xosd_show(@osd))
|
56
|
+
end
|
57
|
+
|
58
|
+
def colour=(colour)
|
59
|
+
handle(XOSD_Bindings.xosd_set_colour(@osd, colour))
|
60
|
+
end
|
61
|
+
|
62
|
+
def font=(font)
|
63
|
+
handle(XOSD_Bindings.xosd_set_font(@osd, font))
|
64
|
+
end
|
65
|
+
|
66
|
+
# :top, :middle, :bottom
|
67
|
+
def position=(position)
|
68
|
+
handle(XOSD_Bindings.xosd_set_pos(@osd, position))
|
69
|
+
end
|
70
|
+
|
71
|
+
# :left, :center, :right
|
72
|
+
def align=(align)
|
73
|
+
handle(XOSD_Bindings.xosd_set_align(@osd, align))
|
74
|
+
end
|
75
|
+
|
76
|
+
def horizontal_offset=(offset)
|
77
|
+
handle(XOSD_Bindings.xosd_set_horizontal_offset(@osd, offset))
|
78
|
+
end
|
79
|
+
|
80
|
+
def vertical_offset=(offset)
|
81
|
+
handle(XOSD_Bindings.xosd_set_vertical_offset(@osd, offset))
|
82
|
+
end
|
83
|
+
|
84
|
+
def outline_offset=(offset)
|
85
|
+
handle(XOSD_Bindings.xosd_set_outline_offset(@osd, offset))
|
86
|
+
end
|
87
|
+
|
88
|
+
def outline_colour=(colour)
|
89
|
+
handle(XOSD_Bindings.xosd_set_outline_colour(@osd, colour))
|
90
|
+
end
|
91
|
+
|
92
|
+
def shadow_offset=(offset)
|
93
|
+
handle(XOSD_Bindings.xosd_set_shadow_offset(@osd, offset))
|
94
|
+
end
|
95
|
+
|
96
|
+
def shadow_colour=(colour)
|
97
|
+
handle(XOSD_Bindings.xosd_set_shadow_colour(@osd, colour))
|
98
|
+
end
|
99
|
+
|
100
|
+
def bar_length=(length)
|
101
|
+
handle(XOSD_Bindings.xosd_set_bar_length(@osd, length))
|
102
|
+
end
|
103
|
+
|
104
|
+
def lines
|
105
|
+
XOSD_Bindings.xosd_get_number_lines(@osd)
|
106
|
+
end
|
107
|
+
|
108
|
+
def timeout=(period)
|
109
|
+
handle(XOSD_Bindings.xosd_set_timeout(@osd, period))
|
110
|
+
end
|
111
|
+
|
112
|
+
def scroll_by(lines)
|
113
|
+
handle(XOSD_Bindings.xosd_scroll(@osd, lines))
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def self.finalize(id)
|
119
|
+
ObjectSpace._id2re(id).teardown
|
120
|
+
end
|
121
|
+
|
122
|
+
def handle(result)
|
123
|
+
raise XOSDError.new(XOSD_Bindings.xosd_error) if result == -1
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module XOSD_Bindings
|
4
|
+
extend FFI::Library
|
5
|
+
ffi_lib ['xosd', 'libxosd.so.2']
|
6
|
+
|
7
|
+
typedef :pointer, :osd
|
8
|
+
|
9
|
+
enum :xosd_command, [:percentage, :string, :printf, :slider]
|
10
|
+
|
11
|
+
enum :xosd_pos, [:top, :bottom, :middle]
|
12
|
+
|
13
|
+
enum :xosd_align, [:left, :center, :right]
|
14
|
+
|
15
|
+
attach_variable :xosd_error, :string
|
16
|
+
attach_variable :osd_default_font, :string
|
17
|
+
attach_variable :osd_default_colour, :string
|
18
|
+
|
19
|
+
# xosd* xosd_create(int number_lines);
|
20
|
+
attach_function :xosd_create, [:int], :osd
|
21
|
+
|
22
|
+
# int xosd_destroy(xosd* osd);
|
23
|
+
attach_function :xosd_destroy, [:osd], :int
|
24
|
+
|
25
|
+
# int xosd_set_bar_length(xosd * osd, int length);
|
26
|
+
attach_function :xosd_set_bar_length, [:osd, :int], :int
|
27
|
+
|
28
|
+
# int xosd_display (xosd* osd, int line, xosd_command command, ...);
|
29
|
+
attach_function :xosd_display, [:osd, :int, :varargs], :int
|
30
|
+
|
31
|
+
# int xosd_is_onscreen(xosd* osd);
|
32
|
+
attach_function :xosd_is_onscreen, [:osd], :int
|
33
|
+
|
34
|
+
# int xosd_wait_until_no_display(xosd* osd);
|
35
|
+
attach_function :xosd_wait_until_no_display, [:osd], :int
|
36
|
+
|
37
|
+
# int xosd_hide (xosd* osd);
|
38
|
+
attach_function :xosd_hide, [:osd], :int
|
39
|
+
|
40
|
+
# int xosd_show (xosd* osd);
|
41
|
+
attach_function :xosd_show, [:osd], :int
|
42
|
+
|
43
|
+
# int xosd_set_pos (xosd* osd, xosd_pos pos);
|
44
|
+
attach_function :xosd_set_pos, [:osd, :xosd_pos], :int
|
45
|
+
|
46
|
+
# int xosd_set_align (xosd* osd, xosd_align align);
|
47
|
+
attach_function :xosd_set_align, [:osd, :xosd_align], :int
|
48
|
+
|
49
|
+
# int xosd_set_shadow_offset (xosd* osd, int shadow_offset);
|
50
|
+
attach_function :xosd_set_shadow_offset, [:osd, :int], :int
|
51
|
+
|
52
|
+
# int xosd_set_outline_offset(xosd * osd, int outline_offset);
|
53
|
+
attach_function :xosd_set_outline_offset, [:osd, :int], :int
|
54
|
+
|
55
|
+
# int xosd_set_outline_colour(xosd * osd, const char *colour);
|
56
|
+
attach_function :xosd_set_outline_colour, [:osd, :string], :int
|
57
|
+
|
58
|
+
# int xosd_set_shadow_colour(xosd * osd, const char *colour);
|
59
|
+
attach_function :xosd_set_shadow_colour, [:osd, :string], :int
|
60
|
+
|
61
|
+
# int xosd_set_horizontal_offset (xosd* osd, int offset);
|
62
|
+
attach_function :xosd_set_horizontal_offset, [:osd, :int], :int
|
63
|
+
|
64
|
+
# int xosd_set_vertical_offset (xosd* osd, int offset);
|
65
|
+
attach_function :xosd_set_vertical_offset, [:osd, :int], :int
|
66
|
+
|
67
|
+
# int xosd_set_timeout (xosd* osd, int timeout);
|
68
|
+
attach_function :xosd_set_timeout, [:osd, :int], :int
|
69
|
+
|
70
|
+
# int xosd_set_colour (xosd* osd, char* colour);
|
71
|
+
attach_function :xosd_set_colour, [:osd, :string], :int
|
72
|
+
|
73
|
+
# int xosd_set_font (xosd* osd, char* font);
|
74
|
+
attach_function :xosd_set_font, [:osd, :string], :int
|
75
|
+
|
76
|
+
# int xosd_get_colour (xosd* osd, int* red, int* green, int* blue);
|
77
|
+
attach_function :xosd_get_colour, [:osd, :pointer, :pointer, :pointer], :int
|
78
|
+
|
79
|
+
# int xosd_scroll (xosd* osd, int lines);
|
80
|
+
attach_function :xosd_scroll, [:osd, :int], :int
|
81
|
+
|
82
|
+
# int xosd_get_number_lines ( xosd* osd);
|
83
|
+
attach_function :xosd_get_number_lines, [:osd], :int
|
84
|
+
end
|
data/lib/xosd.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'xosd/xosd'
|
data/spec/xosd_spec.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'xosd'
|
2
|
+
|
3
|
+
RSpec.describe XOSD do
|
4
|
+
describe 'display string' do
|
5
|
+
it 'displays string' do
|
6
|
+
xosd = XOSD.new
|
7
|
+
xosd.display 'A line to display'
|
8
|
+
xosd.teardown
|
9
|
+
end
|
10
|
+
it 'displays multiple string lines and can scroll them' do
|
11
|
+
xosd = XOSD.new(lines: 3)
|
12
|
+
expect(xosd.lines).to eq 3
|
13
|
+
xosd.display 'First line to display', line: 0
|
14
|
+
xosd.display 'Second line to display', line: 1
|
15
|
+
xosd.display 'Third line to display', line: 2
|
16
|
+
xosd.scroll_by 1
|
17
|
+
xosd.teardown
|
18
|
+
end
|
19
|
+
it 'displays string with options' do
|
20
|
+
xosd = XOSD.new(
|
21
|
+
position: :bottom,
|
22
|
+
align: :center,
|
23
|
+
vertical_offset: 100,
|
24
|
+
font: '-*-arial-*-*-*-*-*-320-*-*-*-*-*-*',
|
25
|
+
colour: 'black',
|
26
|
+
outline_colour: 'orange',
|
27
|
+
outline_offset: 1,
|
28
|
+
shadow_colour: 'white',
|
29
|
+
shadow_offset: 1,
|
30
|
+
timeout: 3
|
31
|
+
)
|
32
|
+
xosd.display 'A line to display on screen'
|
33
|
+
xosd.teardown
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe 'display percentage' do
|
37
|
+
it 'displays percentage bar' do
|
38
|
+
xosd = XOSD.new(bar_length: 100)
|
39
|
+
xosd.display_bar 50
|
40
|
+
xosd.teardown
|
41
|
+
end
|
42
|
+
end
|
43
|
+
describe 'display slider' do
|
44
|
+
it 'displays slider' do
|
45
|
+
xosd = XOSD.new
|
46
|
+
xosd.bar_length = 100
|
47
|
+
xosd.display_slider 50
|
48
|
+
xosd.teardown
|
49
|
+
end
|
50
|
+
end
|
51
|
+
describe 'on screen?' do
|
52
|
+
it 'is true if something is displayed' do
|
53
|
+
xosd = XOSD.new
|
54
|
+
expect(xosd.on_screen?).to be_falsey
|
55
|
+
xosd.display_slider 50
|
56
|
+
expect(xosd.on_screen?).to be_truthy
|
57
|
+
xosd.teardown
|
58
|
+
end
|
59
|
+
end
|
60
|
+
describe 'xosd_wait_until_no_display' do
|
61
|
+
it 'waits for the onscreen message to disappear' do
|
62
|
+
xosd = XOSD.new(timeout: 1)
|
63
|
+
xosd.display_slider 50
|
64
|
+
expect(xosd.on_screen?).to be_truthy
|
65
|
+
xosd.xosd_wait_until_no_display
|
66
|
+
expect(xosd.on_screen?).to be_falsey
|
67
|
+
xosd.teardown
|
68
|
+
end
|
69
|
+
end
|
70
|
+
describe 'hide and show' do
|
71
|
+
it 'hides and shows the message' do
|
72
|
+
xosd = XOSD.new
|
73
|
+
xosd.display_bar 25
|
74
|
+
expect(xosd.on_screen?).to be_truthy
|
75
|
+
xosd.hide
|
76
|
+
sleep 0.1
|
77
|
+
expect(xosd.on_screen?).to be_falsey
|
78
|
+
xosd.show
|
79
|
+
expect(xosd.on_screen?).to be_truthy
|
80
|
+
xosd.teardown
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/xosd.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'xosd'
|
3
|
+
spec.version = '1.0.0'
|
4
|
+
spec.date = '2018-04-30'
|
5
|
+
spec.summary = "Ruby wrapper for xosd"
|
6
|
+
spec.description = "Ruby wrapper for xosd - X on screen display library"
|
7
|
+
spec.authors = ["Yurie Nagorny"]
|
8
|
+
spec.email = 'ynagorny@bearincorp.com'
|
9
|
+
spec.homepage = 'https://github.com/ynagorny/xosd'
|
10
|
+
spec.license = 'MIT'
|
11
|
+
|
12
|
+
git_tracked_files = `git ls-files -z`.split("\x0")
|
13
|
+
gem_ignored_files = `git ls-files -i -X .gemignore -z`.split("\x0")
|
14
|
+
spec.files = git_tracked_files - gem_ignored_files
|
15
|
+
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency 'ffi'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'rspec'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xosd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yurie Nagorny
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruby wrapper for xosd - X on screen display library
|
42
|
+
email: ynagorny@bearincorp.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- Gemfile
|
48
|
+
- Gemfile.lock
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- lib/xosd.rb
|
52
|
+
- lib/xosd/xosd.rb
|
53
|
+
- lib/xosd/xosd_bindings.rb
|
54
|
+
- spec/xosd_spec.rb
|
55
|
+
- xosd.gemspec
|
56
|
+
homepage: https://github.com/ynagorny/xosd
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.5.1
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Ruby wrapper for xosd
|
80
|
+
test_files:
|
81
|
+
- spec/xosd_spec.rb
|