Class: Knj::X11VNC
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(args = {}) ⇒ X11VNC
constructor
A new instance of X11VNC.
- #open? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ X11VNC
Returns a new instance of X11VNC.
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 |
# File 'lib/knj/x11vnc.rb', line 2 def initialize(args = {}) @args = ArrayExt.hash_sym(args) @open = true cmd = "x11vnc -q" cmd << " -shared" if @args[:shared] or !@args.key?(:shared) cmd << " -forever" if @args[:forever] or !@args.key?(:forever) cmd << " -rfbport #{@args[:port]}" if @args[:port] cmd << " -nolookup" if @args[:nolookup] or !@args.key?(:nolookup) print cmd + "\n" @thread = Knj::Thread.new do IO.popen(cmd) do |process| @pid = process.pid process.sync while read = process.read break if read.length == 0 #print read end @open = false @pid = nil @thread = nil end end Kernel.at_exit do self.close end end |
Instance Method Details
#close ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/knj/x11vnc.rb', line 39 def close return nil if !@thread Process.kill("HUP", @pid) if @pid @thread.exit if @thread @thread = nil @open = false @pid = nil end |
#open? ⇒ Boolean
35 36 37 |
# File 'lib/knj/x11vnc.rb', line 35 def open? return @open end |