The Xselection class implement get String from X selection.
new(display)
- Xselection.new(ENV["DISPLAY"])
normal return is nil
raise if illegal display
get()
- get()
return String if X selection has string
return nil if X selection is null
check()
- check()
return String if X selection is changed
return nil if X selection not changed or Xsellection is null
close()
- close()
close display
require 'xselection'
require 'xselection'
require 'jcode'
$KCODE = "e"
raise "DISPLAY is not available." unless ENV["DISPLAY"]
begin
x = Xselection.new(ENV["DISPLAY"])
loop do
str = x.check()
p str if str
sleep(0.3)
end
ensure
x.close()
end
- check $LANG is ja_JP.eucJP - set $KCODE=e or ruby -Ke option