mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-09 21:13:08 +00:00
KRunner: launch via Game Center daemon
Prefer launching through the Game Center DBus daemon and\nfall back to xdg-open for URL-based commands when needed.
This commit is contained in:
parent
fa9c86415f
commit
0485954eb8
2 changed files with 25 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ if(KF6Runner_FOUND)
|
||||||
KF6::I18n
|
KF6::I18n
|
||||||
Qt6::Core
|
Qt6::Core
|
||||||
Qt6::Gui
|
Qt6::Gui
|
||||||
|
Qt6::DBus
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
message(STATUS "KRunner not found, skipping KRunner plugin")
|
message(STATUS "KRunner not found, skipping KRunner plugin")
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
#include "alakarterunner.h"
|
#include "alakarterunner.h"
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
@ -149,13 +152,31 @@ void AlakarteRunner::run(const KRunner::RunnerContext &context, const KRunner::Q
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Steam URLs
|
// Always try daemon first for all commands (including Steam/Lutris)
|
||||||
if (command.startsWith(QLatin1String("steam://"))) {
|
if (!match.id().isEmpty()) {
|
||||||
|
QDBusInterface iface(QStringLiteral("org.kde.GameCenter1"),
|
||||||
|
QStringLiteral("/org/kde/GameCenter1"),
|
||||||
|
QStringLiteral("org.kde.GameCenter1"),
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
QVariantMap launchSpec = {
|
||||||
|
{QStringLiteral("command"), command},
|
||||||
|
{QStringLiteral("gameId"), match.id()},
|
||||||
|
{QStringLiteral("displayName"), match.text()},
|
||||||
|
{QStringLiteral("origin"), QStringLiteral("krunner")},
|
||||||
|
};
|
||||||
|
|
||||||
|
const QDBusReply<QString> reply = iface.call(QStringLiteral("Launch"), launchSpec);
|
||||||
|
if (reply.isValid() && !reply.value().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: daemon unavailable or no game ID
|
||||||
|
if (command.startsWith(QLatin1String("steam://")) || command.startsWith(QLatin1String("lutris:"))) {
|
||||||
QProcess::startDetached(QStringLiteral("xdg-open"), {command});
|
QProcess::startDetached(QStringLiteral("xdg-open"), {command});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle other commands
|
|
||||||
QStringList args = QProcess::splitCommand(command);
|
QStringList args = QProcess::splitCommand(command);
|
||||||
if (!args.isEmpty()) {
|
if (!args.isEmpty()) {
|
||||||
QString program = args.takeFirst();
|
QString program = args.takeFirst();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue