Sha256: 68a4d87887dedcf9bcf90b58ece129bd4a153b2827036d97ac25ba2e2af9b6bd

Contents?: true

Size: 1000 Bytes

Versions: 101

Compression:

Stored size: 1000 Bytes

Contents

class Knj::X11VNC
  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
  
  def open?
    return @open
  end
  
  def close
    return nil if !@thread
    
    Process.kill("HUP", @pid) if @pid
    @thread.exit if @thread
    @thread = nil
    @open = false
    @pid = nil
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
knjrbfw-0.0.72 lib/knj/x11vnc.rb
knjrbfw-0.0.71 lib/knj/x11vnc.rb
knjrbfw-0.0.70 lib/knj/x11vnc.rb
knjrbfw-0.0.69 lib/knj/x11vnc.rb
knjrbfw-0.0.68 lib/knj/x11vnc.rb
knjrbfw-0.0.67 lib/knj/x11vnc.rb
knjrbfw-0.0.66 lib/knj/x11vnc.rb
knjrbfw-0.0.65 lib/knj/x11vnc.rb
knjrbfw-0.0.64 lib/knj/x11vnc.rb
knjrbfw-0.0.63 lib/knj/x11vnc.rb
knjrbfw-0.0.62 lib/knj/x11vnc.rb
knjrbfw-0.0.59 lib/knj/x11vnc.rb
knjrbfw-0.0.58 lib/knj/x11vnc.rb
knjrbfw-0.0.57 lib/knj/x11vnc.rb
knjrbfw-0.0.55 lib/knj/x11vnc.rb
knjrbfw-0.0.54 lib/knj/x11vnc.rb
knjrbfw-0.0.53 lib/knj/x11vnc.rb
knjrbfw-0.0.52 lib/knj/x11vnc.rb
knjrbfw-0.0.51 lib/knj/x11vnc.rb
knjrbfw-0.0.50 lib/knj/x11vnc.rb