Class: RosettAi::DBus::FocusAdapters::KwinAdapter
- Defined in:
- lib/rosett_ai/dbus/focus_adapters/kwin_adapter.rb
Overview
Focus adapter for KDE KWin.
Uses KWin's D-Bus scripting API to monitor focus changes. Listens for the activeWindowChanged signal from org.kde.KWin.
Instance Method Summary collapse
-
#initialize ⇒ KwinAdapter
constructor
A new instance of KwinAdapter.
-
#start ⇒ void
Start the adapter or service.
-
#stop ⇒ void
Stop the adapter or service.
Methods inherited from Base
Constructor Details
#initialize ⇒ KwinAdapter
Returns a new instance of KwinAdapter.
16 17 18 19 20 21 |
# File 'lib/rosett_ai/dbus/focus_adapters/kwin_adapter.rb', line 16 def initialize super @bus = nil @main_loop = nil @thread = nil end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Start the adapter or service.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rosett_ai/dbus/focus_adapters/kwin_adapter.rb', line 25 def start return if @running @bus = ::DBus::SessionBus.instance @running = true setup_signal_handler @thread = Thread.new { run_event_loop } rescue ::DBus::Error => e RosettAi.logger.error("Failed to connect to KWin D-Bus: #{e.}") @running = false end |
#stop ⇒ void
This method returns an undefined value.
Stop the adapter or service.
39 40 41 42 43 44 |
# File 'lib/rosett_ai/dbus/focus_adapters/kwin_adapter.rb', line 39 def stop super @main_loop&.quit @thread&.kill @bus = nil end |