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 =
'be.neatnerds.rosettai'- 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.
24 25 26 27 |
# File 'lib/rosett_ai/dbus/service.rb', line 24 def initialize @running = false @main_loop = nil end |
Instance Attribute Details
#bus ⇒ Object (readonly)
Returns the value of attribute bus.
22 23 24 |
# File 'lib/rosett_ai/dbus/service.rb', line 22 def bus @bus end |
#focus_monitor ⇒ Object (readonly)
Returns the value of attribute focus_monitor.
22 23 24 |
# File 'lib/rosett_ai/dbus/service.rb', line 22 def focus_monitor @focus_monitor end |
#main_loop ⇒ Object (readonly)
Returns the value of attribute main_loop.
22 23 24 |
# File 'lib/rosett_ai/dbus/service.rb', line 22 def main_loop @main_loop end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
22 23 24 |
# File 'lib/rosett_ai/dbus/service.rb', line 22 def manager @manager end |
#status_notifier ⇒ Object (readonly)
Returns the value of attribute status_notifier.
22 23 24 |
# File 'lib/rosett_ai/dbus/service.rb', line 22 def status_notifier @status_notifier end |
Class Method Details
.dbus_available? ⇒ Boolean
Check if D-Bus session bus is available
77 78 79 80 81 82 |
# File 'lib/rosett_ai/dbus/service.rb', line 77 def self.dbus_available? ::DBus::SessionBus.instance true rescue ::DBus::Error false end |
Instance Method Details
#run ⇒ Object
Run the event loop (blocking)
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rosett_ai/dbus/service.rb', line 46 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
70 71 72 |
# File 'lib/rosett_ai/dbus/service.rb', line 70 def running? @running end |
#start ⇒ Boolean
Start the D-Bus service
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rosett_ai/dbus/service.rb', line 32 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 |