Class: RosettAi::Thor::Tasks::DBus
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::DBus
- 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
Constant Summary collapse
- EXIT_SUCCESS =
Returns Exit code for successful D-Bus operation.
0- EXIT_DBUS_FAILURE =
Returns Exit code for D-Bus connection failure.
1- EXIT_MISSING_DEPENDENCY =
Returns Exit code for missing D-Bus dependency.
5- ENV_VARS =
Returns 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.
{ 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
-
#detect ⇒ Array<Hash>
Detect available engines on the system.
-
#start ⇒ void
Start the adapter or service.
-
#status ⇒ String
Return the current status.
-
#stop ⇒ void
Stop the adapter or service.
Instance Method Details
#detect ⇒ Array<Hash>
Detect available engines on the system.
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 |
#start ⇒ void
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 [:daemonize] start_daemon else start_foreground end end |
#status ⇒ String
Return the current status.
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 |
#stop ⇒ void
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 |