Commit 5d1d0e92 authored by David Redondo's avatar David Redondo 🏎
Browse files

Search for desktop files in autostart dir if service was autostarted

BUG:452248
parent 7758d202
Pipeline #172439 passed with stage
in 1 minute and 24 seconds
......@@ -4,6 +4,7 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <QObject>
#include <QStandardPaths>
#include <QTest>
#define private public
#include "cgroup.h"
......@@ -46,6 +47,14 @@ private Q_SLOTS:
QCOMPARE(c.service()->desktopEntryName(), desktopName.toLower());
}
}
void findAutostartApplication()
{
qputenv("XDG_CONFIG_DIRS", QFINDTESTDATA("data").toLocal8Bit());
KSysGuard::CGroup cgroup("app-org.kde.korgac@autostart.service");
QCOMPARE(cgroup.service()->desktopEntryName(), "org.kde.korgac");
QCOMPARE(cgroup.service()->name(), "KOrganizer Reminder Client");
}
};
QTEST_MAIN(CGroupTest);
#include "cgrouptest.moc"
[Desktop Entry]
Name=KOrganizer Reminder Client
Exec=korgac
Icon=korgac
Type=Application
GenericName=KOrganizer Reminder Daemon Client
Terminal=false
X-KDE-autostart-phase=2
X-KDE-autostart-condition=korgacrc:General:Autostart:true
X-DBUS-StartupType=Unique
X-DBUS-ServiceName=org.kde.korgac
#do not uncomment the following line, else autostart fails
#NoDisplay=true
OnlyShowIn=KDE;
......@@ -12,6 +12,7 @@
#include <QFile>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QStandardPaths>
#include <QStringView>
#include <QThreadPool>
......@@ -173,6 +174,12 @@ KService::Ptr CGroupPrivate::serviceFromAppId(const QString &processGroup)
const QString appId = unescapeName(appIdMatch.captured(2));
KService::Ptr service = KService::serviceByMenuId(appId + QStringLiteral(".desktop"));
if (!service && processGroup.endsWith(QLatin1String("@autostart.service"))) {
auto file = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QLatin1String("autostart/%1.desktop").arg(appId));
if (!file.isEmpty()) {
service = new KService(file);
}
}
if (!service) {
service = new KService(appId, QString(), QString());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment