From 462d5f0642d38406ca802f9a4304eeed728d9350 Mon Sep 17 00:00:00 2001 From: Alexey Andreyev Date: Thu, 17 Nov 2022 23:43:01 +0300 Subject: [PATCH] utils/serviceutils: Improve Exec key parsing Take into account Exec field codes. The change makes possible to have both X-KDE-Wayland-Interfaces field (for example, kde_lockscreen_overlay_v1) (and additional arguments for Exec field (for example, %U). See also: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html Contributes to: https://invent.kde.org/plasma-mobile/plasma-dialer/-/merge_requests/105 --- src/utils/serviceutils.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/serviceutils.h b/src/utils/serviceutils.h index 96f181ab02..0a9904d212 100644 --- a/src/utils/serviceutils.h +++ b/src/utils/serviceutils.h @@ -17,6 +17,7 @@ // Qt #include #include +#include // KF #include @@ -31,11 +32,11 @@ static QStringList fetchProcessServiceField(const QString &executablePath, const // needed to be able to use the logging category in a header static function static QLoggingCategory KWIN_UTILS("KWIN_UTILS", QtWarningMsg); const auto servicesFound = KApplicationTrader::query([&executablePath](const KService::Ptr &service) { - if (service->exec().isEmpty() || QFileInfo(service->exec()).canonicalFilePath() != executablePath) { + const auto splitCommandList = QProcess::splitCommand(service->exec()); + if (splitCommandList.isEmpty()) { return false; } - - return true; + return QFileInfo(splitCommandList.first()).canonicalFilePath() == executablePath; }); if (servicesFound.isEmpty()) {