Class: RosettAi::DBus::FocusAdapters::GnomeAdapter
- Defined in:
- lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb
Overview
Focus adapter for GNOME Shell.
Uses GNOME Shell's D-Bus interface to query the focused window. For GNOME < 41, uses org.gnome.Shell.Eval (JavaScript evaluation). For GNOME >= 41, Eval is removed; falls back to xdotool + xprop.
Constant Summary collapse
- POLL_INTERVAL =
seconds
0.5- GNOME_EVAL_REMOVED_VERSION =
41
Instance Method Summary collapse
-
#initialize ⇒ GnomeAdapter
constructor
A new instance of GnomeAdapter.
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Base
#notify_focus_change, #on_focus_change, #running?
Constructor Details
#initialize ⇒ GnomeAdapter
Returns a new instance of GnomeAdapter.
20 21 22 23 24 25 26 27 |
# File 'lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb', line 20 def initialize super @bus = nil @thread = nil @last_app_id = nil @last_title = nil @use_xdotool = false end |
Instance Method Details
#start ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb', line 29 def start return if @running @bus = ::DBus::SessionBus.instance configure_focus_method @running = true @thread = Thread.new { run_poll_loop } rescue ::DBus::Error => e RosettAi.logger.error("Failed to connect to D-Bus: #{e.}") @running = false end |
#stop ⇒ Object
41 42 43 44 45 |
# File 'lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb', line 41 def stop super @thread&.kill @bus = nil end |