86 lines
2.8 KiB
Diff
86 lines
2.8 KiB
Diff
From aeab541e464e7b48020c659b88dc949d3f2e0082 Mon Sep 17 00:00:00 2001
|
|
From: Basil Crow <me@basilcrow.com>
|
|
Date: Mon, 19 Jan 2026 09:52:54 -0800
|
|
Subject: [PATCH] Support logout from `SystemdProvider`
|
|
|
|
---
|
|
lxqtpower/lxqtpowerproviders.cpp | 34 ++++++++++++++++++++++++++++++--
|
|
1 file changed, 32 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/lxqtpower/lxqtpowerproviders.cpp b/lxqtpower/lxqtpowerproviders.cpp
|
|
index 59cc133..6ae0b79 100644
|
|
--- a/lxqtpower/lxqtpowerproviders.cpp
|
|
+++ b/lxqtpower/lxqtpowerproviders.cpp
|
|
@@ -30,6 +30,7 @@
|
|
#include "lxqtpowerproviders.h"
|
|
#include <QDBusInterface>
|
|
#include <QProcess>
|
|
+#include <QProcessEnvironment>
|
|
#include <QGuiApplication>
|
|
#include <QDebug>
|
|
#include "lxqtnotification.h"
|
|
@@ -75,7 +76,8 @@ static bool dbusCall(const QString &service,
|
|
const QString &interface,
|
|
const QDBusConnection &connection,
|
|
const QString & method,
|
|
- PowerProvider::DbusErrorCheck errorCheck = PowerProvider::CheckDBUS
|
|
+ PowerProvider::DbusErrorCheck errorCheck = PowerProvider::CheckDBUS,
|
|
+ const QVariantList &args = QVariantList()
|
|
)
|
|
{
|
|
QDBusInterface dbus(service, path, interface, connection);
|
|
@@ -92,7 +94,7 @@ static bool dbusCall(const QString &service,
|
|
return false;
|
|
}
|
|
|
|
- QDBusMessage msg = dbus.call(method);
|
|
+ QDBusMessage msg = !args.isEmpty() ? dbus.callWithArgumentList(QDBus::Block, method, args) : dbus.call(method);
|
|
|
|
if (!msg.errorName().isEmpty())
|
|
{
|
|
@@ -407,6 +409,19 @@ bool SystemdProvider::canAction(Power::Action action) const
|
|
|
|
switch (action)
|
|
{
|
|
+ case Power::PowerLogout:
|
|
+ {
|
|
+ const QByteArray sessionId = qgetenv("XDG_SESSION_ID");
|
|
+ if (sessionId.isEmpty())
|
|
+ return false;
|
|
+
|
|
+ QDBusInterface dbus(QL1SV(SYSTEMD_SERVICE),
|
|
+ QL1SV(SYSTEMD_PATH),
|
|
+ QL1SV(SYSTEMD_INTERFACE),
|
|
+ QDBusConnection::systemBus());
|
|
+ return dbus.isValid();
|
|
+ }
|
|
+
|
|
case Power::PowerReboot:
|
|
command = QL1SV("CanReboot");
|
|
break;
|
|
@@ -447,6 +462,21 @@ bool SystemdProvider::doAction(Power::Action action)
|
|
|
|
switch (action)
|
|
{
|
|
+ case Power::PowerLogout:
|
|
+ {
|
|
+ const QByteArray sessionId = qgetenv("XDG_SESSION_ID");
|
|
+ if (sessionId.isEmpty())
|
|
+ return false;
|
|
+
|
|
+ return dbusCall(QL1SV(SYSTEMD_SERVICE),
|
|
+ QL1SV(SYSTEMD_PATH),
|
|
+ QL1SV(SYSTEMD_INTERFACE),
|
|
+ QDBusConnection::systemBus(),
|
|
+ QL1SV("TerminateSession"),
|
|
+ PowerProvider::CheckDBUS,
|
|
+ QVariantList() << QString::fromLocal8Bit(sessionId));
|
|
+ }
|
|
+
|
|
case Power::PowerReboot:
|
|
command = QL1SV("Reboot");
|
|
break;
|
|
--
|
|
2.52.0
|
|
|