class Fusuma::Plugin::Appmatcher::Gnome::Matcher
Look up application name using dbus
Public Class Methods
new()
click to toggle source
# File lib/fusuma/plugin/appmatcher/gnome.rb, line 51 def initialize session_bus = DBus.session_bus service = session_bus.service('org.gnome.Shell') @interface = service['/org/gnome/Shell']['org.gnome.Shell'] rescue DBus::Error => e MultiLogger.error "DBus::Error: #{e.message}" exit 1 end
Public Instance Methods
active_application()
click to toggle source
# File lib/fusuma/plugin/appmatcher/gnome.rb, line 70 def active_application # const index = global.get_window_actors() # .findIndex(a=>a.meta_window.has_focus()===true); # global.get_window_actors()[index].get_meta_window().get_wm_class(); gnome_shell_eval( <<~GJS const actor = global.get_window_actors().find(a=>a.meta_window.has_focus()===true) actor && actor.get_meta_window().get_wm_class() GJS ) end
gnome_shell_eval(string)
click to toggle source
TODO def window_title # const index = global.get_window_actors() # .findIndex(a=>a.meta_window.has_focus()===true); # global.get_window_actors().get_meta_window().get_title();
gnome_shell_eval( # <<~GJS # global.get_window_actors().map((current) => { # const wm_class = current.get_meta_window().get_wm_class(); # const title = current.get_meta_window().get_title(); # return { application: wm_class, window_title: title } # }) # GJS )
end
# File lib/fusuma/plugin/appmatcher/gnome.rb, line 98 def gnome_shell_eval(string) success, body = @interface.Eval(string) if success response = begin JSON.parse(body) rescue StandardError nil end return response end raise body end
on_active_application_changed() { |new_application || 'NOT FOUND'| ... }
click to toggle source
# File lib/fusuma/plugin/appmatcher/gnome.rb, line 113 def on_active_application_changed loop do sleep 0.5 new_application = active_application next if @old_application == new_application yield(new_application || 'NOT FOUND') if block_given? @old_application = new_application end end
running_applications()
click to toggle source
@return [Array<Application>]
# File lib/fusuma/plugin/appmatcher/gnome.rb, line 62 def running_applications gnome_shell_eval( <<~GJS global.get_window_actors().map(a => a.get_meta_window().get_wm_class()); GJS ) end