-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxserver.rb
62 lines (47 loc) · 1.54 KB
/
xserver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'childprocess'
# serv = XServer.new 10
# p = serv.build
# p.start
class XServer
attr_reader :display, :id, :process
def initialize(display)
@id = display_to_int(display)
@display = display
end
def build
# Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./10.log -configdir /home/ditrop/dummy -config ./xorg.conf :99
@process = ChildProcess.build("Xorg", "-noreset", "+extension", "GLX","+extension", "RANDR", "+extension", "RENDER",
"-logfile", "./#{id.to_s}.log", "-configdir", "dummy", "-config", "./xorg.conf", "#{display}")
# inherit stdout/stderr from parent...
@process.io.inherit! ## for debug
# ...or pass an IO -> to do
## @process.io.stdout = Tempfile.new("child-output")
# modify the environment for the child
@process.environment["a"] = "b"
@process.environment["c"] = nil
# set the child's working directory
# @process.cwd = '/some/path'
@process
end
def start_vnc
`x11vnc -display :#{@id} -localhost`
sleep 8
`vncviewer :0`
end
end
# # start the process
# @process.start
# # check process status
# @process.alive? #=> true
# @process.exited? #=> false
# # wait indefinitely for process to exit...
# @process.wait
# @process.exited? #=> true
# # get the exit code
# @process.exit_code #=> 0
# # ...or poll for exit + force quit
# begin
# @process.poll_for_exit(10)
# rescue ChildProcess::TimeoutError
# @process.stop # tries increasingly harsher methods to kill the process.
# end