krunner: launch ollie-gui when selecting a session from list

If the GUI is not already running, start it via QProcess and poll
for D-Bus registration before sending SelectSession.
This commit is contained in:
Levi Neely 2026-07-18 23:56:24 +02:00
parent 412d17dda3
commit b5c713443e
1 changed files with 15 additions and 0 deletions

View File

@ -12,6 +12,8 @@
#include <QClipboard>
#include <QApplication>
#include <QLabel>
#include <QProcess>
#include <QThread>
K_PLUGIN_CLASS_WITH_JSON(OllieRunner, "metadata.json")
@ -201,6 +203,19 @@ void OllieRunner::run(const RunnerNS::RunnerContext &context, const RunnerNS::Qu
QDBusConnection::sessionBus());
if (gui.isValid()) {
gui.call(QDBus::NoBlock, "SelectSession", sessionId);
} else {
// GUI not running — launch it, then ask it to select the session
QProcess::startDetached("ollie-gui", {});
// Poll for D-Bus registration (up to 3 seconds)
for (int i = 0; i < 30; ++i) {
QThread::msleep(100);
QDBusInterface retry("org.ollie.Gui", "/org/ollie/Gui", "org.ollie.Gui",
QDBusConnection::sessionBus());
if (retry.isValid()) {
retry.call(QDBus::NoBlock, "SelectSession", sessionId);
break;
}
}
}
}