From fd3ca82346ca8eceecab509c1bd29f57f6f7242c Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 6 Jun 2024 14:48:46 +0800 Subject: [PATCH] chore: add instance on start state get all states `systemctl --state=help` use ListUnitsByPatterns to list Units --- src/dbus/applicationmanager1service.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dbus/applicationmanager1service.cpp b/src/dbus/applicationmanager1service.cpp index c87f8c2..57f5c71 100644 --- a/src/dbus/applicationmanager1service.cpp +++ b/src/dbus/applicationmanager1service.cpp @@ -321,7 +321,12 @@ void ApplicationManager1Service::scanApplications() noexcept void ApplicationManager1Service::scanInstances() noexcept { auto &conn = ApplicationManager1DBus::instance().globalDestBus(); - auto call_message = QDBusMessage::createMethodCall(SystemdService, SystemdObjectPath, SystemdInterfaceName, "ListUnits"); + auto call_message = + QDBusMessage::createMethodCall(SystemdService, SystemdObjectPath, SystemdInterfaceName, "ListUnitsByPatterns"); + QList args; + args << QVariant::fromValue(QStringList{"running", "start"}); + args << QVariant::fromValue(QStringList{"dde*", "deepin*"}); + call_message.setArguments(args); auto result = conn.call(call_message); if (result.type() == QDBusMessage::ErrorMessage) { qCritical() << "failed to scan existing instances: call to ListUnits failed:" << result.errorMessage(); @@ -332,9 +337,7 @@ void ApplicationManager1Service::scanInstances() noexcept QList units; v.value() >> units; for (const auto &unit : units) { - if (unit.subState == "running") { - this->addInstanceToApplication(unit.name, unit.objectPath); - } + this->addInstanceToApplication(unit.name, unit.objectPath); } }