Module: RosettAi::DBus::CompositorDetector

Defined in:
lib/rosett_ai/dbus/compositor_detector.rb

Overview

Detects the current compositor/window manager.

Detection order (first match wins):

  1. HYPRLAND_INSTANCE_SIGNATURE env var → :hyprland
  2. SWAYSOCK env var → :sway
  3. I3SOCK env var → :i3
  4. org.gnome.Shell D-Bus name active → :gnome
  5. org.kde.KWin D-Bus name active → :kwin
  6. DISPLAY set, WAYLAND_DISPLAY unset → :x11
  7. else → :unknown

Constant Summary collapse

COMPOSITOR_CHECKS =
[
  { env: 'HYPRLAND_INSTANCE_SIGNATURE', type: :hyprland },
  { env: 'SWAYSOCK', type: :sway },
  { env: 'I3SOCK', type: :i3 }
].freeze
DBUS_NAMES =
{
  'org.gnome.Shell' => :gnome,
  'org.kde.KWin' => :kwin
}.freeze

Class Method Summary collapse

Class Method Details

.detectSymbol

Detect the current compositor

Returns:

  • (Symbol)

    Compositor type



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rosett_ai/dbus/compositor_detector.rb', line 36

def detect
  # Check environment variables first
  COMPOSITOR_CHECKS.each do |check|
    return check[:type] if ENV.key?(check[:env])
  end

  # Check D-Bus names
  compositor = detect_via_dbus
  return compositor if compositor

  # Check for X11
  return :x11 if x11_only?

  :unknown
end