Class: RosettAi::DBus::FocusAdapters::X11Adapter

Inherits:
Base
  • Object
show all
Defined in:
lib/rosett_ai/dbus/focus_adapters/x11_adapter.rb

Overview

Focus adapter for X11 window managers.

Uses xprop to monitor _NET_ACTIVE_WINDOW property changes. Falls back to polling if xprop spy mode is not available.

Constant Summary collapse

POLL_INTERVAL =

seconds

0.5

Instance Method Summary collapse

Methods inherited from Base

#on_focus_change, #running?

Constructor Details

#initializeX11Adapter

Returns a new instance of X11Adapter.



16
17
18
19
20
21
# File 'lib/rosett_ai/dbus/focus_adapters/x11_adapter.rb', line 16

def initialize
  super
  @thread = nil
  @xprop_process = nil
  @last_window_id = nil
end

Instance Method Details

#startvoid

This method returns an undefined value.

Start the adapter or service.



25
26
27
28
29
30
31
# File 'lib/rosett_ai/dbus/focus_adapters/x11_adapter.rb', line 25

def start
  return if @running
  return unless xprop_available?

  @running = true
  @thread = Thread.new { run_poll_loop }
end

#stopvoid

This method returns an undefined value.

Stop the adapter or service.



35
36
37
38
39
# File 'lib/rosett_ai/dbus/focus_adapters/x11_adapter.rb', line 35

def stop
  super
  @thread&.kill
  @xprop_process&.close
end