Changeset View
Changeset View
Standalone View
Standalone View
startkde/startplasma.cpp
Show All 27 Lines | |||||
28 | 28 | | |||
29 | #include <KConfig> | 29 | #include <KConfig> | ||
30 | #include <KConfigGroup> | 30 | #include <KConfigGroup> | ||
31 | 31 | | |||
32 | #include <unistd.h> | 32 | #include <unistd.h> | ||
33 | 33 | | |||
34 | #include "startplasma.h" | 34 | #include "startplasma.h" | ||
35 | 35 | | |||
36 | #include "../config-workspace.h" | ||||
37 | | ||||
38 | | ||||
36 | QTextStream out(stderr); | 39 | QTextStream out(stderr); | ||
37 | 40 | | |||
38 | void messageBox(const QString &text) | 41 | void messageBox(const QString &text) | ||
39 | { | 42 | { | ||
40 | out << text; | 43 | out << text; | ||
41 | runSync(QStringLiteral("xmessage"), {QStringLiteral("-geometry"), QStringLiteral("500x100"), text}); | 44 | runSync(QStringLiteral("xmessage"), {QStringLiteral("-geometry"), QStringLiteral("500x100"), text}); | ||
42 | } | 45 | } | ||
43 | 46 | | |||
▲ Show 20 Lines • Show All 301 Lines • ▼ Show 20 Line(s) | 340 | { | |||
345 | // kwrapper5 is used to reduce startup time and memory usage | 348 | // kwrapper5 is used to reduce startup time and memory usage | ||
346 | // kwrapper5 does not return useful error codes such as the exit code of ksmserver. | 349 | // kwrapper5 does not return useful error codes such as the exit code of ksmserver. | ||
347 | // We only check for 255 which means that the ksmserver process could not be | 350 | // We only check for 255 which means that the ksmserver process could not be | ||
348 | // started, any problems thereafter, e.g. ksmserver failing to initialize, | 351 | // started, any problems thereafter, e.g. ksmserver failing to initialize, | ||
349 | // will remain undetected. | 352 | // will remain undetected. | ||
350 | // If the session should be locked from the start (locked autologin), | 353 | // If the session should be locked from the start (locked autologin), | ||
351 | // lock now and do the rest of the KDE startup underneath the locker. | 354 | // lock now and do the rest of the KDE startup underneath the locker. | ||
352 | 355 | | |||
356 | bool rc = true; | ||||
357 | QEventLoop e; | ||||
358 | | ||||
359 | QDBusServiceWatcher serviceWatcher; | ||||
360 | serviceWatcher.setConnection(QDBusConnection::sessionBus()); | ||||
361 | | ||||
362 | // We want to exit when both ksmserver and plasma-session-shutdown have finished | ||||
363 | // This also closes if ksmserver crashes unexpectedly, as in those cases plasma-shutdown is not running | ||||
364 | serviceWatcher.addWatchedService(QStringLiteral("org.kde.ksmserver")); | ||||
365 | serviceWatcher.addWatchedService(QStringLiteral("org.kde.shutdown")); | ||||
366 | serviceWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); | ||||
367 | | ||||
368 | QObject::connect(&serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, [&]() { | ||||
369 | const QStringList watchedServices = serviceWatcher.watchedServices(); | ||||
370 | bool plasmaSessionRunning = std::any_of(watchedServices.constBegin(), watchedServices.constEnd(), [](const QString &service) { | ||||
371 | return QDBusConnection::sessionBus().interface()->isServiceRegistered(service); | ||||
372 | }); | ||||
373 | if (!plasmaSessionRunning) { | ||||
374 | e.quit(); | ||||
375 | } | ||||
376 | }); | ||||
377 | | ||||
378 | #ifndef PLASMA_SYSTEMD_BOOT | ||||
379 | QProcess startPlasmaSession; | ||||
353 | 380 | | |||
354 | QStringList plasmaSessionOptions; | 381 | QStringList plasmaSessionOptions; | ||
355 | if (wayland) { | 382 | if (wayland) { | ||
356 | plasmaSessionOptions << QStringLiteral("--no-lockscreen"); | 383 | plasmaSessionOptions << QStringLiteral("--no-lockscreen"); | ||
357 | } else { | 384 | } else { | ||
358 | if (qEnvironmentVariableIsSet("KDEWM")) { | 385 | if (qEnvironmentVariableIsSet("KDEWM")) { | ||
359 | plasmaSessionOptions << QStringLiteral("--windowmanager") << qEnvironmentVariable("KDEWM"); | 386 | plasmaSessionOptions << QStringLiteral("--windowmanager") << qEnvironmentVariable("KDEWM"); | ||
360 | } | 387 | } | ||
361 | if (desktopLockedAtStart) { | 388 | if (desktopLockedAtStart) { | ||
362 | plasmaSessionOptions << QStringLiteral("--lockscreen"); | 389 | plasmaSessionOptions << QStringLiteral("--lockscreen"); | ||
363 | } | 390 | } | ||
364 | } | 391 | } | ||
365 | 392 | | |||
366 | bool rc = true; | | |||
367 | QEventLoop e; | | |||
368 | | ||||
369 | QProcess startPlasmaSession; | | |||
370 | startPlasmaSession.setProcessChannelMode(QProcess::ForwardedChannels); | 393 | startPlasmaSession.setProcessChannelMode(QProcess::ForwardedChannels); | ||
371 | | ||||
372 | QDBusServiceWatcher serviceWatcher; | | |||
373 | serviceWatcher.setConnection(QDBusConnection::sessionBus()); | | |||
374 | | ||||
375 | // We want to exit when both ksmserver and plasma-session-shutdown have finished | | |||
376 | // This also closes if ksmserver crashes unexpectedly, as in those cases plasma-shutdown is not running | | |||
377 | serviceWatcher.addWatchedService(QStringLiteral("org.kde.ksmserver")); | | |||
378 | serviceWatcher.addWatchedService(QStringLiteral("org.kde.shutdown")); | | |||
379 | serviceWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); | | |||
380 | | ||||
381 | QObject::connect(&startPlasmaSession, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [&rc, &e](int exitCode, QProcess::ExitStatus) { | 394 | QObject::connect(&startPlasmaSession, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [&rc, &e](int exitCode, QProcess::ExitStatus) { | ||
382 | if (exitCode == 255) { | 395 | if (exitCode == 255) { | ||
383 | // Startup error | 396 | // Startup error | ||
384 | messageBox(QStringLiteral("startkde: Could not start ksmserver. Check your installation.\n")); | 397 | messageBox(QStringLiteral("startkde: Could not start ksmserver. Check your installation.\n")); | ||
385 | rc = false; | 398 | rc = false; | ||
386 | e.quit(); | 399 | e.quit(); | ||
387 | } | 400 | } | ||
388 | }); | 401 | }); | ||
389 | 402 | | |||
390 | QObject::connect(&serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, [&]() { | 403 | startPlasmaSession.start(QStringLiteral(CMAKE_INSTALL_FULL_BINDIR "/plasma_session"), plasmaSessionOptions); | ||
391 | const QStringList watchedServices = serviceWatcher.watchedServices(); | 404 | rc = startPlasmaSession.waitForStarted(); | ||
hchain: unrelated change ? | |||||
392 | bool plasmaSessionRunning = std::any_of(watchedServices.constBegin(), watchedServices.constEnd(), [](const QString &service) { | 405 | #else | ||
393 | return QDBusConnection::sessionBus().interface()->isServiceRegistered(service); | 406 | auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"), | ||
394 | }); | 407 | QStringLiteral("/org/freedesktop/systemd1"), | ||
395 | if (!plasmaSessionRunning) { | 408 | QStringLiteral("org.freedesktop.systemd1.Manager"), | ||
396 | e.quit(); | 409 | QStringLiteral("StartUnit")); | ||
410 | msg << QStringLiteral("plasma-workspace.target") << QStringLiteral("fail"); | ||||
411 | auto reply = QDBusConnection::sessionBus().call(msg); | ||||
412 | if (reply.type() == QDBusMessage::ErrorMessage) { | ||||
413 | rc = false; | ||||
397 | } | 414 | } | ||
398 | }); | 415 | #endif | ||
399 | 416 | | |||
400 | startPlasmaSession.start(QStringLiteral(CMAKE_INSTALL_FULL_BINDIR "/plasma_session"), plasmaSessionOptions); | 417 | if (rc) { | ||
401 | e.exec(); | 418 | e.exec(); | ||
419 | } | ||||
402 | return rc; | 420 | return rc; | ||
403 | } | 421 | } | ||
404 | 422 | | |||
405 | void waitForKonqi() | 423 | void waitForKonqi() | ||
406 | { | 424 | { | ||
407 | const KConfig cfg(QStringLiteral("startkderc")); | 425 | const KConfig cfg(QStringLiteral("startkderc")); | ||
408 | const KConfigGroup grp = cfg.group("WaitForDrKonqi"); | 426 | const KConfigGroup grp = cfg.group("WaitForDrKonqi"); | ||
409 | bool wait_drkonqi = grp.readEntry("Enabled", true); | 427 | bool wait_drkonqi = grp.readEntry("Enabled", true); | ||
Show All 20 Lines |
unrelated change ?