Class: RosettAi::Thor::Tasks::DBus

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/dbus.rb

Overview

Thor task for D-Bus service management.

Exit codes:

0 — success
1 — D-Bus connection failure
5 — missing ruby-dbus dependency

Author:

  • hugo

  • claude

Constant Summary collapse

EXIT_SUCCESS =

Returns Exit code for successful D-Bus operation.

Returns:

  • (Integer)

    Exit code for successful D-Bus operation.

0
EXIT_DBUS_FAILURE =

Returns Exit code for D-Bus connection failure.

Returns:

  • (Integer)

    Exit code for D-Bus connection failure.

1
EXIT_MISSING_DEPENDENCY =

Returns Exit code for missing D-Bus dependency.

Returns:

  • (Integer)

    Exit code for missing D-Bus dependency.

5
ENV_VARS =

Returns Environment variables checked for compositor detection.

Returns:

  • (Array)

    Environment variables checked for compositor detection.

[
  'SWAYSOCK', 'I3SOCK', 'HYPRLAND_INSTANCE_SIGNATURE', 'DISPLAY', 'WAYLAND_DISPLAY', 'XDG_RUNTIME_DIR', 'XDG_SESSION_TYPE'
].freeze
ADAPTER_MAP =

Returns Maps compositor names to focus adapter classes.

Returns:

  • (Hash)

    Maps compositor names to focus adapter classes.

{
  sway: 'I3Adapter (i3ipc)',
  i3: 'I3Adapter (i3ipc)',
  hyprland: 'HyprlandAdapter (socket2)',
  gnome: 'GnomeAdapter (Shell D-Bus)',
  kwin: 'KwinAdapter (KWin D-Bus)',
  x11: 'X11Adapter (xprop)'
}.freeze

Instance Method Summary collapse

Instance Method Details

#detectArray<Hash>

Detect available engines on the system.

Returns:

  • (Array<Hash>)


161
162
163
164
165
166
167
168
169
170
# File 'lib/rosett_ai/thor/tasks/dbus.rb', line 161

def detect
  require_desktop_gems!
  compositor = RosettAi::DBus::CompositorDetector.detect

  if tty_output?
    print_detect_tty(compositor)
  else
    print_detect_json(compositor)
  end
end

#startvoid

This method returns an undefined value.

Start the adapter or service.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rosett_ai/thor/tasks/dbus.rb', line 102

def start
  require_desktop_gems!
  check_dbus_availability

  if service_running?
    warn Rainbow(t('already_running')).yellow
    return
  end

  if options[:daemonize]
    start_daemon
  else
    start_foreground
  end
end

#statusString

Return the current status.

Returns:

  • (String)


64
65
66
67
68
69
70
71
72
73
# File 'lib/rosett_ai/thor/tasks/dbus.rb', line 64

def status
  require_desktop_gems!
  check_dbus_availability

  if service_running?
    print_running_status
  else
    print_not_running
  end
end

#stopvoid

This method returns an undefined value.

Stop the adapter or service.



135
136
137
138
139
140
141
142
143
144
# File 'lib/rosett_ai/thor/tasks/dbus.rb', line 135

def stop
  require_desktop_gems!
  unless service_running?
    warn Rainbow(t('not_running')).yellow
    return
  end

  stop_via_dbus
  warn Rainbow(t('stopped')).green
end