[startkde] Move kwin launching to systemd / plasma-session

Currently we have a whole daisy-chain of startplasmawayland-> kwin ->
startplasmawaylandsession -> launching the session.

This was needed as we needed environment variables which previously we
only knew after kwin started.

After some kwin refactoring this is no longer the case, and
kwin_wayland_wrapper will sync it's environment variables to the
appropriate startup environments.

This allows us to move starting kwin_wayland to be systemd managed,
brining resource control, alongside it's classic counterpart
plasma-session.
wilder-5.24
David Edmundson 5 years ago
parent 3a1603a4e1
commit 7884f53d3c
  1. 2
      ksmserver/plasma-ksmserver.service.in
  2. 5
      startkde/CMakeLists.txt
  3. 1
      startkde/kcminit/plasma-kcminit.service.in
  4. 30
      startkde/plasma-session/startup.cpp
  5. 20
      startkde/startplasma-wayland.cpp
  6. 42
      startkde/startplasma-waylandsession.cpp
  7. 3
      startkde/systemd/plasma-core.target

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=KDE Session Management Server Description=KDE Session Management Server
Wants=plasma-kcminit.service
PartOf=graphical-session.target PartOf=graphical-session.target
After=plasma-kwin_wayland.service plasma-kcminit.service
[Service] [Service]
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/ksmserver ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/ksmserver

@ -30,7 +30,6 @@ target_link_libraries(startplasma PUBLIC
add_executable(startplasma-x11 ${START_PLASMA_COMMON_SRCS} startplasma-x11.cpp kcheckrunning/kcheckrunning.cpp) add_executable(startplasma-x11 ${START_PLASMA_COMMON_SRCS} startplasma-x11.cpp kcheckrunning/kcheckrunning.cpp)
add_executable(startplasma-wayland ${START_PLASMA_COMMON_SRCS} startplasma-wayland.cpp) add_executable(startplasma-wayland ${START_PLASMA_COMMON_SRCS} startplasma-wayland.cpp)
add_executable(startplasma-waylandsession ${START_PLASMA_COMMON_SRCS} startplasma-waylandsession.cpp)
target_link_libraries(startplasma-x11 PRIVATE target_link_libraries(startplasma-x11 PRIVATE
startplasma startplasma
@ -41,9 +40,6 @@ target_link_libraries(startplasma-wayland PRIVATE
startplasma startplasma
) )
target_link_libraries(startplasma-waylandsession PRIVATE
startplasma
)
add_subdirectory(plasma-session) add_subdirectory(plasma-session)
add_subdirectory(plasma-shutdown) add_subdirectory(plasma-shutdown)
@ -57,6 +53,5 @@ configure_file(config-startplasma.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-sta
install(TARGETS startplasma-x11 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS startplasma-x11 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS startplasma-wayland ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS startplasma-wayland ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS startplasma-waylandsession DESTINATION ${KDE_INSTALL_LIBEXECDIR})
install(PROGRAMS plasma-sourceenv.sh DESTINATION ${KDE_INSTALL_LIBEXECDIR}) install(PROGRAMS plasma-sourceenv.sh DESTINATION ${KDE_INSTALL_LIBEXECDIR})
install(PROGRAMS plasma-dbus-run-session-if-needed DESTINATION ${KDE_INSTALL_LIBEXECDIR}) install(PROGRAMS plasma-dbus-run-session-if-needed DESTINATION ${KDE_INSTALL_LIBEXECDIR})

@ -1,6 +1,7 @@
[Unit] [Unit]
Description=KDE Config Module Initialization Description=KDE Config Module Initialization
PartOf=graphical-session.target PartOf=graphical-session.target
After=plasma-kwin_wayland.service
[Service] [Service]
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/kcminit_startup ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/kcminit_startup

@ -148,10 +148,7 @@ Startup::Startup(QObject *parent)
const AutoStart autostart; const AutoStart autostart;
// Keep for KF5; remove in KF6 (KInit will be gone then) KJob *x11WindowManagerJob = nullptr;
QProcess::execute(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/start_kdeinit_wrapper"), QStringList());
KJob *windowManagerJob = nullptr;
if (qEnvironmentVariable("XDG_SESSION_TYPE") != QLatin1String("wayland")) { if (qEnvironmentVariable("XDG_SESSION_TYPE") != QLatin1String("wayland")) {
QString windowManager; QString windowManager;
if (qEnvironmentVariableIsSet("KDEWM")) { if (qEnvironmentVariableIsSet("KDEWM")) {
@ -162,19 +159,38 @@ Startup::Startup(QObject *parent)
} }
if (windowManager == QLatin1String(KWIN_BIN)) { if (windowManager == QLatin1String(KWIN_BIN)) {
windowManagerJob = new StartServiceJob(windowManager, {}, QStringLiteral("org.kde.KWin")); x11WindowManagerJob = new StartServiceJob(windowManager, {}, QStringLiteral("org.kde.KWin"));
} else { } else {
windowManagerJob = new StartServiceJob(windowManager, {}, {}); x11WindowManagerJob = new StartServiceJob(windowManager, {}, {});
}
} else {
// This must block until started as it sets the WAYLAND_DISPLAY/DISPLAY env variables needed for the rest of the boot
// fortunately it's very fast as it's just starting a wrapper
StartServiceJob kwinWaylandJob(QStringLiteral("kwin_wayland_wrapper"), {QStringLiteral("--xwayland")}, QStringLiteral("org.kde.KWinWrapper"));
kwinWaylandJob.exec();
// kslpash is only launched in plasma-session from the wayland mode, for X it's in startplasma-x11
const KConfig cfg(QStringLiteral("ksplashrc"));
// the splashscreen and progress indicator
KConfigGroup ksplashCfg = cfg.group("KSplash");
if (ksplashCfg.readEntry("Engine", QStringLiteral("KSplashQML")) == QLatin1String("KSplashQML")) {
QProcess::startDetached(QStringLiteral("ksplashqml"), {ksplashCfg.readEntry("Theme", QStringLiteral("Breeze"))});
} }
// FIXME 1: this code path is missing setupFontDpi() after X has started. Move to kcminit?
// FIXME 2: the systemd path has no concept of kslpash
// FIXME 3: the systemd code path is missing setupFontDpi
} }
// Keep for KF5; remove in KF6 (KInit will be gone then)
QProcess::execute(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/start_kdeinit_wrapper"), QStringList());
KJob *phase1 = nullptr; KJob *phase1 = nullptr;
m_lock.reset(new QEventLoopLocker); m_lock.reset(new QEventLoopLocker);
const QVector<KJob *> sequence = { const QVector<KJob *> sequence = {
new StartProcessJob(QStringLiteral("kcminit_startup"), {}), new StartProcessJob(QStringLiteral("kcminit_startup"), {}),
new StartServiceJob(QStringLiteral("kded5"), {}, QStringLiteral("org.kde.kded5"), {}), new StartServiceJob(QStringLiteral("kded5"), {}, QStringLiteral("org.kde.kded5"), {}),
windowManagerJob, x11WindowManagerJob,
new StartServiceJob(QStringLiteral("ksmserver"), QCoreApplication::instance()->arguments().mid(1), QStringLiteral("org.kde.ksmserver")), new StartServiceJob(QStringLiteral("ksmserver"), QCoreApplication::instance()->arguments().mid(1), QStringLiteral("org.kde.ksmserver")),
new StartupPhase0(autostart, this), new StartupPhase0(autostart, this),
phase1 = new StartupPhase1(autostart, this), phase1 = new StartupPhase1(autostart, this),

@ -82,16 +82,16 @@ int main(int argc, char **argv)
// variables (e.g. LANG and LC_*) // variables (e.g. LANG and LC_*)
importSystemdEnvrionment(); importSystemdEnvrionment();
QStringList args; if (!startPlasmaSession(true))
if (argc > 1) { return 4;
args.reserve(argc);
for (int i = 1; i < argc; ++i) { // Anything after here is logout
args << QString::fromLocal8Bit(argv[i]); // It is not called after shutdown/restart
} waitForKonqi();
} else { out << "startplasma-wayland: Shutting down...\n";
args = QStringList{QStringLiteral("--xwayland"), QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR "/startplasma-waylandsession")};
} // Keep for KF5; remove in KF6 (KInit will be gone then)
runSync(QStringLiteral("kwin_wayland_wrapper"), args); runSync(QStringLiteral("kdeinit5_shutdown"), {});
out << "startplasmacompositor: Shutting down...\n"; out << "startplasmacompositor: Shutting down...\n";
cleanupPlasmaEnvironment(oldSystemdEnvironment); cleanupPlasmaEnvironment(oldSystemdEnvironment);

@ -1,42 +0,0 @@
/*
SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "startplasma.h"
#include <signal.h>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
signal(SIGTERM, sigtermHandler);
QScopedPointer<QProcess, KillBeforeDeleter> ksplash;
if (!qEnvironmentVariableIsSet("KWIN_RESTART_COUNT")) {
ksplash.reset(setupKSplash());
}
out << "startplasma-waylandsession: Starting up...\n";
if (!syncDBusEnvironment()) {
out << "Could not sync environment to dbus.\n";
return 2;
}
if (!startPlasmaSession(true))
return 4;
// Anything after here is logout
// It is not called after shutdown/restart
waitForKonqi();
out << "startplasma-waylandsession: Shutting down...\n";
// Keep for KF5; remove in KF6 (KInit will be gone then)
runSync(QStringLiteral("kdeinit5_shutdown"), {});
out << "startplasma-waylandsession: Done.\n";
return 0;
}

@ -2,6 +2,5 @@
Description=KDE Plasma Workspace Core Description=KDE Plasma Workspace Core
Wants=plasma-plasmashell.service plasma-kcminit.service plasma-kded.service plasma-kcminit-phase1.service graphical-session-pre.target Wants=plasma-plasmashell.service plasma-kcminit.service plasma-kded.service plasma-kcminit-phase1.service graphical-session-pre.target
Requires=plasma-ksmserver.service Requires=plasma-ksmserver.service
BindsTo=plasma-ksmserver.service After=graphical-session-pre.target plasma-kwin_wayland.service
After=graphical-session-pre.target
RefuseManualStart=yes RefuseManualStart=yes

Loading…
Cancel
Save