chore: add instance on start state
get all states `systemctl --state=help` use ListUnitsByPatterns to list Units
This commit is contained in:
parent
e14d7b9540
commit
fd3ca82346
@ -321,7 +321,12 @@ void ApplicationManager1Service::scanApplications() noexcept
|
|||||||
void ApplicationManager1Service::scanInstances() noexcept
|
void ApplicationManager1Service::scanInstances() noexcept
|
||||||
{
|
{
|
||||||
auto &conn = ApplicationManager1DBus::instance().globalDestBus();
|
auto &conn = ApplicationManager1DBus::instance().globalDestBus();
|
||||||
auto call_message = QDBusMessage::createMethodCall(SystemdService, SystemdObjectPath, SystemdInterfaceName, "ListUnits");
|
auto call_message =
|
||||||
|
QDBusMessage::createMethodCall(SystemdService, SystemdObjectPath, SystemdInterfaceName, "ListUnitsByPatterns");
|
||||||
|
QList<QVariant> args;
|
||||||
|
args << QVariant::fromValue(QStringList{"running", "start"});
|
||||||
|
args << QVariant::fromValue(QStringList{"dde*", "deepin*"});
|
||||||
|
call_message.setArguments(args);
|
||||||
auto result = conn.call(call_message);
|
auto result = conn.call(call_message);
|
||||||
if (result.type() == QDBusMessage::ErrorMessage) {
|
if (result.type() == QDBusMessage::ErrorMessage) {
|
||||||
qCritical() << "failed to scan existing instances: call to ListUnits failed:" << result.errorMessage();
|
qCritical() << "failed to scan existing instances: call to ListUnits failed:" << result.errorMessage();
|
||||||
@ -332,11 +337,9 @@ void ApplicationManager1Service::scanInstances() noexcept
|
|||||||
QList<SystemdUnitDBusMessage> units;
|
QList<SystemdUnitDBusMessage> units;
|
||||||
v.value<QDBusArgument>() >> units;
|
v.value<QDBusArgument>() >> units;
|
||||||
for (const auto &unit : units) {
|
for (const auto &unit : units) {
|
||||||
if (unit.subState == "running") {
|
|
||||||
this->addInstanceToApplication(unit.name, unit.objectPath);
|
this->addInstanceToApplication(unit.name, unit.objectPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QHash<QSharedPointer<ApplicationService>, QString> ApplicationManager1Service::scanAutoStart() noexcept
|
QHash<QSharedPointer<ApplicationService>, QString> ApplicationManager1Service::scanAutoStart() noexcept
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user