Commit 799db613 authored by David Edmundson's avatar David Edmundson
Browse files

Restore following XDG_SESSION_ID env if set

BUG: 435468

Testing done:
Ran on a VT with an XDG_SESSION_ID from another terminal, ensured it
switched
parent c103eb8f
......@@ -61,11 +61,19 @@ static const QString s_managerPath = QStringLiteral("/org/freedesktop/login1");
static QString findProcessSessionPath()
{
QDBusMessage message = QDBusMessage::createMethodCall(s_serviceName, s_managerPath,
s_managerInterface,
QStringLiteral("GetSessionByPID"));
message.setArguments({ uint32_t(QCoreApplication::applicationPid()) });
const QString sessionId = qEnvironmentVariable("XDG_SESSION_ID");
QDBusMessage message;
if (sessionId.isEmpty()) {
message = QDBusMessage::createMethodCall(s_serviceName, s_managerPath,
s_managerInterface,
QStringLiteral("GetSessionByPID"));
message.setArguments({uint32_t(QCoreApplication::applicationPid())});
} else {
message = QDBusMessage::createMethodCall(s_serviceName, s_managerPath,
s_managerInterface,
QStringLiteral("GetSession"));
message.setArguments({sessionId});
}
const QDBusMessage reply = QDBusConnection::systemBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
return 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