class Fusuma::Plugin::Appmatcher::X11
Search Active Window's Name
Attributes
matcher[R]
reader[R]
writer[R]
Public Class Methods
new()
click to toggle source
# File lib/fusuma/plugin/appmatcher/x11.rb, line 15 def initialize @reader, @writer = IO.pipe end
Public Instance Methods
watch_start()
click to toggle source
fork process and watch signal @return [Integer] Process id
# File lib/fusuma/plugin/appmatcher/x11.rb, line 21 def watch_start @watch_start ||= begin pid = UserSwitcher.new.as_user do |_user| @reader.close register_on_application_changed(Matcher.new) end Process.detach(pid) pid end end
Private Instance Methods
notify(name)
click to toggle source
# File lib/fusuma/plugin/appmatcher/x11.rb, line 40 def notify(name) @writer.puts(name) rescue Errno::EPIPE exit 0 rescue StandardError => e MultiLogger.error e.message exit 1 end
register_on_application_changed(matcher)
click to toggle source
# File lib/fusuma/plugin/appmatcher/x11.rb, line 34 def register_on_application_changed(matcher) matcher.on_active_application_changed do |name| notify(name) end end