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
63
64
65
|
# File 'lib/network-projector/client/app.rb', line 8
def run!
options = {:passwd=>'unsecure', :host=>'localhost', :display=>":0", :clip => "xinerama0", :user=>Socket.gethostname}
parser = OptionParser.new
parser.on('--help', 'displays usage information') do
puts parser
exit
end
parser.on('-h=HOST', '--host=HOST', "Projector host (#{options[:host]})") do |v|
options[:host] = v
end
parser.on('-d=DISPLAY', '--display=HOST', "Local display to share (#{options[:display]})") do |v|
options[:display] = v
end
parser.on('-u=USER', '--user=USER', "User label (#{options[:label]})") do |v|
options[:user] = v
end
parser.on('-p=PASSWD', '--passwd=PASSWD', 'Vnc password') do |v|
options[:passwd] = v
end
begin
parser.parse($*)
rescue OptionParser::ParseError
puts $!
exit
end
@user = options[:user]
@vs = VncShare.new options
@vs.run
if not @vs.started? then
puts "Can't start, leaving"
return
end
begin
@http = Net::HTTP.new(options[:host], 4567)
connect
puts "Ready for connection"
@vs.join
rescue SystemCallError => e
puts "Connection to #{options[:host]}:4567 failed : #{e}"
@vs.stop
rescue Interrupt
@vs.stop
ensure
disconnect
end
puts "Leaving"
end
|