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)


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

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



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

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>)


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

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