Class: RosettAi::DBus::Service
- Inherits:
-
Object
- Object
- RosettAi::DBus::Service
- Defined in:
- lib/rosett_ai/dbus/service.rb
Overview
Main D-Bus session service for Rosett-AI.
Exports interfaces under be.neatnerds.rosettai bus name:
- be.neatnerds.rosettai.Manager: compile, context switching, status
- be.neatnerds.rosettai.FocusMonitor: active window tracking
- org.kde.StatusNotifierItem: system tray presence
The service is designed to gracefully degrade when D-Bus is unavailable.
Constant Summary collapse
- BUS_NAME =
Returns D-Bus well-known bus name.
'be.neatnerds.rosettai'- OBJECT_PATH =
Returns D-Bus object path.
'/be/neatnerds/rosett-ai'
Instance Attribute Summary collapse
-
#bus ⇒ Object
readonly
Returns the value of attribute bus.
-
#focus_monitor ⇒ Object
readonly
Returns the value of attribute focus_monitor.
-
#main_loop ⇒ Object
readonly
Returns the value of attribute main_loop.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#status_notifier ⇒ Object
readonly
Returns the value of attribute status_notifier.
Class Method Summary collapse
-
.dbus_available? ⇒ Boolean
Check if D-Bus session bus is available.
Instance Method Summary collapse
-
#initialize ⇒ Service
constructor
A new instance of Service.
-
#run ⇒ Object
Run the event loop (blocking).
-
#running? ⇒ Boolean
Check if the service is running.
-
#start ⇒ Boolean
Start the D-Bus service.
-
#stop ⇒ Object
Stop the D-Bus service.
Constructor Details
#initialize ⇒ Service
Returns a new instance of Service.
27 28 29 30 |
# File 'lib/rosett_ai/dbus/service.rb', line 27 def initialize @running = false @main_loop = nil end |
Instance Attribute Details
#bus ⇒ Object (readonly)
Returns the value of attribute bus.
25 26 27 |
# File 'lib/rosett_ai/dbus/service.rb', line 25 def bus @bus end |
#focus_monitor ⇒ Object (readonly)
Returns the value of attribute focus_monitor.
25 26 27 |
# File 'lib/rosett_ai/dbus/service.rb', line 25 def focus_monitor @focus_monitor end |
#main_loop ⇒ Object (readonly)
Returns the value of attribute main_loop.
25 26 27 |
# File 'lib/rosett_ai/dbus/service.rb', line 25 def main_loop @main_loop end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
25 26 27 |
# File 'lib/rosett_ai/dbus/service.rb', line 25 def manager @manager end |
#status_notifier ⇒ Object (readonly)
Returns the value of attribute status_notifier.
25 26 27 |
# File 'lib/rosett_ai/dbus/service.rb', line 25 def status_notifier @status_notifier end |
Class Method Details
.dbus_available? ⇒ Boolean
Check if D-Bus session bus is available
80 81 82 83 84 85 |
# File 'lib/rosett_ai/dbus/service.rb', line 80 def self.dbus_available? ::DBus::SessionBus.instance true rescue ::DBus::Error false end |
Instance Method Details
#run ⇒ Object
Run the event loop (blocking)
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rosett_ai/dbus/service.rb', line 49 def run return unless @running @main_loop = ::DBus::Main.new @main_loop << @bus RosettAi.logger.info("D-Bus service running on #{BUS_NAME}") @main_loop.run rescue Interrupt stop end |
#running? ⇒ Boolean
Check if the service is running
73 74 75 |
# File 'lib/rosett_ai/dbus/service.rb', line 73 def running? @running end |
#start ⇒ Boolean
Start the D-Bus service
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rosett_ai/dbus/service.rb', line 35 def start return false if @running connect_to_session_bus export_interfaces request_bus_name @running = true true rescue ::DBus::Error => e RosettAi.logger.error("D-Bus service failed to start: #{e.}") false end |