File indexing completed on 2024-05-05 05:38:56
0001 /* 0002 SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "startplasma.h" 0008 0009 #include <KConfig> 0010 #include <KConfigGroup> 0011 #include <signal.h> 0012 #include <unistd.h> 0013 0014 void sighupHandler(int) 0015 { 0016 out << "GOT SIGHUP\n"; 0017 } 0018 0019 int main(int argc, char **argv) 0020 { 0021 // When the X server dies we get a HUP signal from xinit. We must ignore it 0022 // because we still need to do some cleanup. 0023 signal(SIGHUP, sighupHandler); 0024 qputenv("QT_NO_XDG_DESKTOP_PORTAL", QByteArrayLiteral("1")); 0025 0026 QCoreApplication app(argc, argv); 0027 0028 // Check if a Plasma session already is running and whether it's possible to connect to X 0029 switch (kCheckRunning()) { 0030 case NoX11: 0031 out << "$DISPLAY is not set or cannot connect to the X server.\n"; 0032 return 1; 0033 case PlasmaRunning: 0034 messageBox(QStringLiteral("Plasma seems to be already running on this display.\n")); 0035 return 1; 0036 case NoPlasmaRunning: 0037 break; 0038 } 0039 0040 createConfigDirectory(); 0041 runStartupConfig(); 0042 0043 // Do not sync any of this section with the wayland versions as there scale factors are 0044 // sent properly over wl_output 0045 0046 { 0047 KConfig cfg(QStringLiteral("kdeglobals")); 0048 0049 KConfigGroup kscreenGroup = cfg.group(QStringLiteral("KScreen")); 0050 const auto screenScaleFactors = kscreenGroup.readEntry("ScreenScaleFactors", QByteArray()); 0051 if (!screenScaleFactors.isEmpty()) { 0052 qputenv("QT_SCREEN_SCALE_FACTORS", screenScaleFactors); 0053 } 0054 } 0055 0056 // NOTE: Be very mindful of what you start this early in the process. The environment is not yet complete. 0057 setupCursor(false); 0058 std::unique_ptr<QProcess, KillBeforeDeleter> ksplash(setupKSplash()); 0059 Q_UNUSED(ksplash) 0060 0061 runEnvironmentScripts(); 0062 0063 out << "startkde: Starting up...\n"; 0064 0065 setupPlasmaEnvironment(); 0066 0067 qunsetenv("QT_NO_XDG_DESKTOP_PORTAL"); 0068 auto oldSystemdEnvironment = getSystemdEnvironment(); 0069 if (!syncDBusEnvironment()) { 0070 // Startup error 0071 messageBox(QStringLiteral("Could not sync environment to dbus.\n")); 0072 return 1; 0073 } 0074 0075 // We import systemd environment after we sync the dbus environment here. 0076 // Otherwise it may leads to some unwanted order of applying environment 0077 // variables (e.g. LANG and LC_*) 0078 importSystemdEnvrionment(); 0079 0080 if (!startPlasmaSession(false)) 0081 return 1; 0082 0083 // Anything after here is logout 0084 // It is not called after shutdown/restart 0085 waitForKonqi(); 0086 0087 out << "startkde: Shutting down...\n"; 0088 0089 // Keep for KF5; remove in KF6 (KInit will be gone then) 0090 runSync(QStringLiteral("kdeinit5_shutdown"), {}); 0091 0092 cleanupPlasmaEnvironment(oldSystemdEnvironment); 0093 0094 out << "startkde: Done.\n"; 0095 0096 return 0; 0097 }