Class: RosettAi::DBus::FocusAdapters::HyprlandAdapter

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

Overview

Focus adapter for Hyprland compositor.

Uses Hyprland's IPC socket2 to receive activewindow events. Socket path: $XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock

Instance Method Summary collapse

Methods inherited from Base

#notify_focus_change, #on_focus_change, #running?

Constructor Details

#initializeHyprlandAdapter

Returns a new instance of HyprlandAdapter.



14
15
16
17
18
# File 'lib/rosett_ai/dbus/focus_adapters/hyprland_adapter.rb', line 14

def initialize
  super
  @socket = nil
  @thread = nil
end

Instance Method Details

#startObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/dbus/focus_adapters/hyprland_adapter.rb', line 20

def start
  return if @running

  socket_path = hyprland_socket_path
  unless socket_path && File.exist?(socket_path)
    RosettAi.logger.error('Hyprland socket not found')
    return
  end

  @socket = UNIXSocket.new(socket_path)
  @running = true
  @thread = Thread.new { run_event_loop }
rescue StandardError => e
  RosettAi.logger.error("Failed to connect to Hyprland: #{e.message}")
  @running = false
end

#stopObject



37
38
39
40
41
42
# File 'lib/rosett_ai/dbus/focus_adapters/hyprland_adapter.rb', line 37

def stop
  super
  @thread&.kill
  @socket&.close
  @socket = nil
end