[plasma/plasma-login-manager] src/frontend/startkde: Merge startplasma and startplasmawayland
David Edmundson <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit a097d3bd2ae33a74010dc6e438ce1074ec271625 by David Edmundson.
Committed on 20/07/2026 at 13:57.
Pushed by davidedmundson into branch 'master'.
Merge startplasma and startplasmawayland
There are no behavioural changes
M +1 -1 src/frontend/startkde/CMakeLists.txt
M +103 -0 src/frontend/startkde/startplasma.cpp
D +0 -117 src/frontend/startkde/startplasmalogin-wayland.cpp
https://invent.kde.org/plasma/plasma-login-manager/-/commit/a097d3bd2ae33a74010dc6e438ce1074ec271625
diff --git a/src/frontend/startkde/CMakeLists.txt b/src/frontend/startkde/CMakeLists.txt
index 774d0773..f9f67ee9 100644
--- a/src/frontend/startkde/CMakeLists.txt
+++ b/src/frontend/startkde/CMakeLists.txt
@@ -3,7 +3,7 @@ ecm_install_configured_files(INPUT plasma-login-kwin_wayland.service.in DESTINAT
ecm_qt_declare_logging_category(startplasma_SRCS HEADER debug.h IDENTIFIER PLASMA_STARTUP CATEGORY_NAME org.kde.startup)
-add_executable(startplasma-login-wayland startplasmalogin-wayland.cpp startplasma.cpp ${startplasma_SRCS})
+add_executable(startplasma-login-wayland startplasma.cpp ${startplasma_SRCS})
target_link_libraries(startplasma-login-wayland PRIVATE
Qt::Core
Qt::DBus
diff --git a/src/frontend/startkde/startplasma.cpp b/src/frontend/startkde/startplasma.cpp
index 42ceab07..9fe0a6a0 100644
--- a/src/frontend/startkde/startplasma.cpp
+++ b/src/frontend/startkde/startplasma.cpp
@@ -16,6 +16,8 @@
#include "debug.h"
#include <QCoreApplication>
+#include <QDBusArgument>
+#include <QDebug>
#include <QDir>
#include <QEventLoop>
#include <QProcess>
@@ -23,6 +25,7 @@
#include <QDBusConnectionInterface>
#include <QDBusMetaType>
+#include <QDBusReply>
#include <QDBusServiceWatcher>
#include <KConfig>
@@ -33,6 +36,7 @@
#include <KPackage/PackageLoader>
#include <KSharedConfig>
+#include <signal.h>
#include <unistd.h>
// #include <autostartscriptdesktopfile.h>
@@ -426,3 +430,102 @@ void resetSystemdFailedUnits()
QStringLiteral("ResetFailed"));
QDBusConnection::sessionBus().call(message);
}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ createConfigDirectory();
+ signal(SIGTERM, sigtermHandler);
+
+ // Let clients try to reconnect to kwin after a restart
+ qputenv("QT_WAYLAND_RECONNECT", "1");
+
+ // Query whether org.freedesktop.locale1 is available. If it is, try to
+ // set XKB_DEFAULT_{MODEL,LAYOUT,VARIANT,OPTIONS} accordingly.
+ {
+ const QString locale1Service = QStringLiteral("org.freedesktop.locale1");
+ const QString locale1Path = QStringLiteral("/org/freedesktop/locale1");
+ QDBusMessage message =
+ QDBusMessage::createMethodCall(locale1Service, locale1Path, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("GetAll"));
+ message << locale1Service;
+ QDBusMessage resultMessage = QDBusConnection::systemBus().call(message);
+ if (resultMessage.type() == QDBusMessage::ReplyMessage) {
+ QVariantMap result;
+ QDBusArgument dbusArgument = resultMessage.arguments().at(0).value<QDBusArgument>();
+ while (!dbusArgument.atEnd()) {
+ dbusArgument >> result;
+ }
+
+ auto queryAndSet = [&result](const char *var, const QString &value) {
+ const auto r = result.value(value).toString();
+ if (!r.isEmpty()) {
+ qputenv(var, r.toUtf8());
+ }
+ };
+
+ queryAndSet("XKB_DEFAULT_MODEL", QStringLiteral("X11Model"));
+ queryAndSet("XKB_DEFAULT_LAYOUT", QStringLiteral("X11Layout"));
+ queryAndSet("XKB_DEFAULT_VARIANT", QStringLiteral("X11Variant"));
+ queryAndSet("XKB_DEFAULT_OPTIONS", QStringLiteral("X11Options"));
+ } else {
+ qWarning() << "not a reply org.freedesktop.locale1" << resultMessage;
+ }
+ }
+
+ setupPlasmaEnvironment();
+ runStartupConfig();
+
+ auto oldSystemdEnvironment = getSystemdEnvironment();
+ if (!syncDBusEnvironment()) {
+ out << "Could not sync environment to dbus.\n";
+ return 1;
+ };
+
+ {
+ auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
+ QStringLiteral("/org/freedesktop/systemd1"),
+ QStringLiteral("org.freedesktop.systemd1.Manager"),
+ QStringLiteral("StartUnit"));
+ msg << QStringLiteral("plasma-login-wayland.target") << QStringLiteral("fail");
+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(msg);
+ if (!reply.isValid()) {
+ qWarning() << "Could not start systemd managed Plasma session:" << reply.error().name() << reply.error().message();
+ }
+ }
+
+ // stopped by the sigterm handler
+ app.exec();
+
+ qDebug() << "stopping";
+
+ {
+ auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
+ QStringLiteral("/org/freedesktop/systemd1"),
+ QStringLiteral("org.freedesktop.systemd1.Manager"),
+ QStringLiteral("StopUnit"));
+ msg << QStringLiteral("plasma-login-wayland.target") << QStringLiteral("fail");
+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(msg);
+ if (!reply.isValid()) {
+ qWarning() << "Could not stop systemd managed Plasma session:" << reply.error().name() << reply.error().message();
+ }
+ }
+
+ qDebug() << "final cleanup";
+
+ // systemd returns when the call is made, but not all jobs are torn down
+ // this waits until kwin is definitely gone too, which helps logind
+ {
+ auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
+ QStringLiteral("/org/freedesktop/systemd1"),
+ QStringLiteral("org.freedesktop.systemd1.Manager"),
+ QStringLiteral("StopUnit"));
+ msg << QStringLiteral("plasma-login-kwin_wayland.service") << QStringLiteral("fail");
+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(msg);
+ if (!reply.isValid()) {
+ qWarning() << "Could not close up systemd managed Plasma session:" << reply.error().name() << reply.error().message();
+ }
+ }
+
+ return 0;
+}
diff --git a/src/frontend/startkde/startplasmalogin-wayland.cpp b/src/frontend/startkde/startplasmalogin-wayland.cpp
deleted file mode 100644
index de90ad1e..00000000
--- a/src/frontend/startkde/startplasmalogin-wayland.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <[email protected]>
-
- SPDX-License-Identifier: LGPL-2.0-or-later
-*/
-
-#include "startplasma.h"
-#include <KConfig>
-#include <KConfigGroup>
-#include <QDBusArgument>
-#include <QDBusConnection>
-#include <QDBusInterface>
-#include <QDBusReply>
-#include <QDebug>
-
-#include <QCoreApplication>
-#include <qdbusservicewatcher.h>
-#include <signal.h>
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- createConfigDirectory();
- signal(SIGTERM, sigtermHandler);
-
- // Let clients try to reconnect to kwin after a restart
- qputenv("QT_WAYLAND_RECONNECT", "1");
-
- // Query whether org.freedesktop.locale1 is available. If it is, try to
- // set XKB_DEFAULT_{MODEL,LAYOUT,VARIANT,OPTIONS} accordingly.
- {
- const QString locale1Service = QStringLiteral("org.freedesktop.locale1");
- const QString locale1Path = QStringLiteral("/org/freedesktop/locale1");
- QDBusMessage message =
- QDBusMessage::createMethodCall(locale1Service, locale1Path, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("GetAll"));
- message << locale1Service;
- QDBusMessage resultMessage = QDBusConnection::systemBus().call(message);
- if (resultMessage.type() == QDBusMessage::ReplyMessage) {
- QVariantMap result;
- QDBusArgument dbusArgument = resultMessage.arguments().at(0).value<QDBusArgument>();
- while (!dbusArgument.atEnd()) {
- dbusArgument >> result;
- }
-
- auto queryAndSet = [&result](const char *var, const QString &value) {
- const auto r = result.value(value).toString();
- if (!r.isEmpty()) {
- qputenv(var, r.toUtf8());
- }
- };
-
- queryAndSet("XKB_DEFAULT_MODEL", QStringLiteral("X11Model"));
- queryAndSet("XKB_DEFAULT_LAYOUT", QStringLiteral("X11Layout"));
- queryAndSet("XKB_DEFAULT_VARIANT", QStringLiteral("X11Variant"));
- queryAndSet("XKB_DEFAULT_OPTIONS", QStringLiteral("X11Options"));
- } else {
- qWarning() << "not a reply org.freedesktop.locale1" << resultMessage;
- }
- }
-
- setupPlasmaEnvironment();
- runStartupConfig();
-
- auto oldSystemdEnvironment = getSystemdEnvironment();
- if (!syncDBusEnvironment()) {
- out << "Could not sync environment to dbus.\n";
- return 1;
- };
-
- {
- auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
- QStringLiteral("/org/freedesktop/systemd1"),
- QStringLiteral("org.freedesktop.systemd1.Manager"),
- QStringLiteral("StartUnit"));
- msg << QStringLiteral("plasma-login-wayland.target") << QStringLiteral("fail");
- QDBusReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(msg);
- if (!reply.isValid()) {
- qWarning() << "Could not start systemd managed Plasma session:" << reply.error().name() << reply.error().message();
- }
- }
-
- // stopped by the sigterm handler
- app.exec();
-
- qDebug() << "stopping";
-
- {
- auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
- QStringLiteral("/org/freedesktop/systemd1"),
- QStringLiteral("org.freedesktop.systemd1.Manager"),
- QStringLiteral("StopUnit"));
- msg << QStringLiteral("plasma-login-wayland.target") << QStringLiteral("fail");
- QDBusReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(msg);
- if (!reply.isValid()) {
- qWarning() << "Could not stop systemd managed Plasma session:" << reply.error().name() << reply.error().message();
- }
- }
-
- qDebug() << "final cleanup";
-
- // systemd returns when the call is made, but not all jobs are torn down
- // this waits until kwin is definitely gone too, which helps logind
- {
- auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
- QStringLiteral("/org/freedesktop/systemd1"),
- QStringLiteral("org.freedesktop.systemd1.Manager"),
- QStringLiteral("StopUnit"));
- msg << QStringLiteral("plasma-login-kwin_wayland.service") << QStringLiteral("fail");
- QDBusReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(msg);
- if (!reply.isValid()) {
- qWarning() << "Could not close up systemd managed Plasma session:" << reply.error().name() << reply.error().message();
- }
- }
-
- return 0;
-}