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 =
Returns GNOME version that removed Eval D-Bus interface.
41
Instance Method Summary collapse
-
#initialize ⇒ GnomeAdapter
constructor
A new instance of GnomeAdapter.
-
#start ⇒ void
Start the adapter or service.
-
#stop ⇒ void
Stop the adapter or service.
Methods inherited from Base
Constructor Details
#initialize ⇒ GnomeAdapter
Returns a new instance of GnomeAdapter.
21 22 23 24 25 26 27 28 |
# File 'lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb', line 21 def initialize super @bus = nil @thread = nil @last_app_id = nil @last_title = nil @use_xdotool = false end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Start the adapter or service.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb', line 32 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 ⇒ void
This method returns an undefined value.
Stop the adapter or service.
46 47 48 49 50 |
# File 'lib/rosett_ai/dbus/focus_adapters/gnome_adapter.rb', line 46 def stop super @thread&.kill @bus = nil end |