diff --git a/src/cthulhu/dbus_service.py b/src/cthulhu/dbus_service.py index 8f6900a..a32dedc 100644 --- a/src/cthulhu/dbus_service.py +++ b/src/cthulhu/dbus_service.py @@ -488,6 +488,23 @@ if _dasbus_available: debug.printMessage(debug.LEVEL_INFO, msg, True) return result + def Quit(self) -> bool: # pylint: disable=invalid-name + """Quits Cthulhu. Returns True if the quit request was accepted.""" + + msg = "DBUS SERVICE: Quit called." + debug.printMessage(debug.LEVEL_INFO, msg, True) + + from . import cthulhu # pylint: disable=import-outside-toplevel + + # cthulhu.shutdown() shuts down the dbus service, so send the response immediately and then + # do the actual shutdown after a brief delay. + def _delayed_shutdown(): + cthulhu.shutdown() + return False + + GLib.timeout_add(100, _delayed_shutdown) + return True + def shutdown_service(self, bus: SessionMessageBus, object_path_base: str) -> None: """Releases D-Bus resources held by this service and its modules."""