Class: Fusuma::Plugin::Appmatcher::X11::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/plugin/appmatcher/x11.rb

Overview

Look up application name using xprop

Instance Method Summary collapse

Instance Method Details

#active_application(id = active_window_id) ⇒ String, NilClass

Returns:

  • (String)
  • (NilClass)


60
61
62
63
64
65
66
67
# File 'lib/fusuma/plugin/appmatcher/x11.rb', line 60

def active_application(id = active_window_id)
  @cache ||= {}
  @cache[id] ||= if id.nil?
                   nil
                 else
                   `xprop -id #{id} WM_CLASS | cut -d "=" -f 2 | tr -d '"'`.strip.split(", ").last
                 end
end

#on_active_application_changedObject



69
70
71
72
73
# File 'lib/fusuma/plugin/appmatcher/x11.rb', line 69

def on_active_application_changed
  active_window_id(watch: true) do |id|
    yield(active_application(id) || "NOT FOUND")
  end
end

#running_applicationsArray<String>

Returns:

  • (Array<String>)


52
53
54
55
56
# File 'lib/fusuma/plugin/appmatcher/x11.rb', line 52

def running_applications
  `xprop -root _NET_CLIENT_LIST_STACKING`.split(", ")
                                         .map { |id_str| id_str.match(/0x[\da-z]{2,}/).to_s }
                                         .map { |id| active_application(id) }
end