lib/fusuma/plugin/appmatcher/gnome.rb in fusuma-plugin-appmatcher-0.4.0 vs lib/fusuma/plugin/appmatcher/gnome.rb in fusuma-plugin-appmatcher-0.5.0
- old
+ new
@@ -7,26 +7,27 @@
module Fusuma
module Plugin
module Appmatcher
# Search Active Window's Name
class Gnome
- attr_reader :matcher, :reader, :writer
+ include UserSwitcher
+ attr_reader :reader, :writer
+
def initialize
@reader, @writer = IO.pipe
end
# fork process and watch signal
# @return [Integer] Process id
def watch_start
@watch_start ||= begin
- pid = UserSwitcher.new.as_user(proctitle: self.class.name.underscore) do |user|
+ pid = as_user(proctitle: self.class.name.underscore) do |user|
@reader.close
ENV["DBUS_SESSION_BUS_ADDRESS"] = "unix:path=/run/user/#{user.uid}/bus"
register_on_application_changed(Matcher.new)
end
- Process.detach(pid)
pid
end
end
private
@@ -39,11 +40,11 @@
def notify(name)
@writer.puts(name)
rescue Errno::EPIPE
exit 0
- rescue StandardError => e
+ rescue => e
MultiLogger.error e.message
exit 1
end
# Look up application name using dbus
@@ -99,10 +100,10 @@
success, body = @interface.Eval(string)
if success
response = begin
JSON.parse(body)
- rescue StandardError
+ rescue
nil
end
return response
end