diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e99937ad..aae1bf553 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,207 +1,210 @@ cmake_minimum_required(VERSION 3.0) project(plasma-workspace) set(PROJECT_VERSION "5.19.80") set(PROJECT_VERSION_MAJOR 5) set(QT_MIN_VERSION "5.14.0") set(KF5_MIN_VERSION "5.71.0") set(INSTALL_SDDM_THEME TRUE) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Widgets Quick QuickWidgets Concurrent Test Network) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMMarkNonGuiExecutable) include(CMakePackageConfigHelpers) include(WriteBasicConfigVersionFile) include(CheckIncludeFiles) include(FeatureSummary) include(ECMOptionalAddSubdirectory) include(ECMQtDeclareLoggingCategory) include(ECMQueryQmake) include(KDEPackageAppTemplates) include(KDEClangFormat) +include(ECMConfiguredInstall) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma DocTools Runner Notifications NotifyConfig Su NewStuff Wallet IdleTime Declarative I18n KCMUtils TextWidgets KDELibs4Support Crash GlobalAccel DBusAddons Wayland CoreAddons People ActivitiesStats Activities) find_package(KDED CONFIG REQUIRED) find_package(KF5NetworkManagerQt ${KF5_MIN_VERSION}) set_package_properties(KF5NetworkManagerQt PROPERTIES DESCRIPTION "Qt wrapper for NetworkManager API" TYPE OPTIONAL PURPOSE "Needed by geolocation data engine." ) find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5Kirigami2 PROPERTIES DESCRIPTION "A QtQuick based components set" TYPE RUNTIME ) find_package(KF5QuickCharts ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5QuickCharts PROPERTIES DESCRIPTION "Used for rendering charts" TYPE RUNTIME ) # WARNING PlasmaQuick provides unversioned CMake config find_package(KUserFeedback) find_package(KF5 REQUIRED COMPONENTS PlasmaQuick) find_package(KSysGuard CONFIG REQUIRED) find_package(KF5 REQUIRED COMPONENTS Package) find_package(KF5Baloo) set_package_properties(KF5Baloo PROPERTIES DESCRIPTION "File Searching" TYPE RECOMMENDED PURPOSE "Needed for the File Search runner." ) find_package(KF5TextEditor) find_package(KWinDBusInterface CONFIG REQUIRED) find_package(KF5Screen CONFIG REQUIRED) find_package(KScreenLocker 5.13.80 REQUIRED) find_package(ScreenSaverDBusInterface CONFIG REQUIRED) find_package(KF5Holidays) set_package_properties(KF5Holidays PROPERTIES DESCRIPTION "Holidays provider for Plasma calendar" TYPE OPTIONAL PURPOSE "Needed to for holidays plugin for Plasma Calendar." ) find_package(Phonon4Qt5 4.6.60 REQUIRED NO_MODULE) set_package_properties(Phonon4Qt5 PROPERTIES DESCRIPTION "Qt-based audio library" TYPE REQUIRED) find_package(ZLIB) set_package_properties(ZLIB PROPERTIES DESCRIPTION "Support for gzip compressed files and data streams" URL "https://www.zlib.net" TYPE REQUIRED ) find_package(X11) set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" URL "https://www.x.org" TYPE OPTIONAL PURPOSE "Required for building the X11 based workspace") if(X11_FOUND) find_package(XCB MODULE REQUIRED COMPONENTS XCB RANDR) set_package_properties(XCB PROPERTIES TYPE REQUIRED) if(NOT X11_SM_FOUND) message(FATAL_ERROR "\nThe X11 Session Management (SM) development package could not be found.\nPlease install libSM.\n") endif(NOT X11_SM_FOUND) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras) endif() if(X11_FOUND AND XCB_XCB_FOUND) set(HAVE_X11 1) endif() find_package(AppStreamQt 0.10.6) set_package_properties(AppStreamQt PROPERTIES DESCRIPTION "Access metadata for listing available software" URL "https://www.freedesktop.org/wiki/Distributions/AppStream/" TYPE OPTIONAL ) if(${AppStreamQt_FOUND}) set(HAVE_APPSTREAMQT true) endif() include(ConfigureChecks.cmake) include_directories("${CMAKE_CURRENT_BINARY_DIR}") configure_file(config-workspace.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-workspace.h) configure_file(config-unix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-unix.h ) configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h) configure_file(config-appstream.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-appstream.h ) add_subdirectory(login-sessions) plasma_install_package(lookandfeel org.kde.breeze.desktop look-and-feel lookandfeel) if (INSTALL_SDDM_THEME) configure_file(sddm-theme/theme.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/sddm-theme/theme.conf) # Install the login theme into the SDDM directory # Longer term we need to look at making SDDM load from look and feel somehow.. and allow copying at runtime #NOTE this trailing slash is important to rename the directory install(DIRECTORY sddm-theme/ DESTINATION ${KDE_INSTALL_FULL_DATADIR}/sddm/themes/breeze PATTERN "README.txt" EXCLUDE PATTERN "components" EXCLUDE PATTERN "dummydata" EXCLUDE PATTERN "theme.conf.cmake" EXCLUDE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sddm-theme/theme.conf DESTINATION ${KDE_INSTALL_FULL_DATADIR}/sddm/themes/breeze) install(DIRECTORY lookandfeel/contents/components DESTINATION ${KDE_INSTALL_FULL_DATADIR}/sddm/themes/breeze PATTERN "README.txt" EXCLUDE) endif() add_definitions(-DQT_NO_URL_CAST_FROM_STRING) # locate qdbus in the Qt path because not every distro makes a symlink at /usr/bin/qdbus query_qmake(QtBinariesDir QT_INSTALL_BINS) +option(PLASMA_SYSTEMD_BOOT "Use systemd units for startup of plasma (WIP)" FALSE) + add_subdirectory(doc) add_subdirectory(libkworkspace) add_subdirectory(libdbusmenuqt) add_subdirectory(appmenu) add_subdirectory(libtaskmanager) add_subdirectory(libnotificationmanager) add_subdirectory(libcolorcorrect) add_subdirectory(components) add_subdirectory(plasma-windowed) add_subdirectory(shell) add_subdirectory(freespacenotifier) add_subdirectory(klipper) add_subdirectory(krunner) add_subdirectory(ksmserver) add_subdirectory(logout-greeter) add_subdirectory(ksplash) add_subdirectory(systemmonitor) add_subdirectory(statusnotifierwatcher) add_subdirectory(startkde) add_subdirectory(themes) add_subdirectory(kcms) add_subdirectory(containmentactions) add_subdirectory(runners) add_subdirectory(applets) add_subdirectory(dataengines) add_subdirectory(wallpapers) add_subdirectory(kioslave) add_subdirectory(ktimezoned) add_subdirectory(menu) add_subdirectory(phonon) # This ensures pressing the eject button on a CD drive ejects the disc # It listens to the Solid::OpticalDrive::ejectPressed signal that is only # supported by Solid in the HAL backend and does nothing with UDev if(CMAKE_SYSTEM_NAME MATCHES FreeBSD) add_subdirectory(solidautoeject) endif() ecm_optional_add_subdirectory(xembed-sni-proxy) ecm_optional_add_subdirectory(gmenu-dbusmenu-proxy) add_subdirectory(soliduiserver) if(KF5Holidays_FOUND) add_subdirectory(plasmacalendarintegration) endif() add_subdirectory(templates) install(FILES plasma-workspace.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) # add clang-format target for all our real source files file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) diff --git a/config-workspace.h.cmake b/config-workspace.h.cmake index ee41da342..6dd636aa7 100644 --- a/config-workspace.h.cmake +++ b/config-workspace.h.cmake @@ -1,157 +1,159 @@ /* config-workspace.h. Generated by cmake from config-workspace.h.cmake */ #cmakedefine HAVE_QIMAGEBLITZ /* Define if you have DPMS support */ #cmakedefine HAVE_DPMS 1 /* Define if you have the DPMSCapable prototype in */ #cmakedefine HAVE_DPMSCAPABLE_PROTO 1 /* Define if you have the DPMSInfo prototype in */ #cmakedefine HAVE_DPMSINFO_PROTO 1 /* Defines if your system has the libfontconfig library */ #cmakedefine HAVE_FONTCONFIG 1 /* Defines if your system has the freetype library */ #cmakedefine HAVE_FREETYPE 1 /* Define if you have gethostname */ #cmakedefine HAVE_GETHOSTNAME 1 /* Define if you have the gethostname prototype */ #cmakedefine HAVE_GETHOSTNAME_PROTO 1 /* Define to 1 if you have the `getpeereid' function. */ #cmakedefine HAVE_GETPEEREID 1 /* Defines if you have Solaris' libkstat */ /* #undef HAVE_KSTAT */ /* Define if you have long long as datatype */ #cmakedefine HAVE_LONG_LONG 1 /* Define to 1 if you have the `nice' function. */ #cmakedefine HAVE_NICE 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SASL_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SASL_SASL_H 1 /* Define to 1 if you have the `setpriority' function. */ #cmakedefine HAVE_SETPRIORITY 1 /* Define to 1 if you have the `sigaction' function. */ #cmakedefine HAVE_SIGACTION 1 /* Define to 1 if you have the `sigset' function. */ #cmakedefine HAVE_SIGSET 1 /* Define to 1 if you have statvfs */ #cmakedefine HAVE_STATVFS 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRING_H 1 /* Define if you have the struct ucred */ #cmakedefine HAVE_STRUCT_UCRED 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_LOADAVG_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_MOUNT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_STATFS_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_STATVFS_H 1 /* Define to 1 if you have statfs(). */ #cmakedefine HAVE_STATFS 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_VFS_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_WAIT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MALLOC_H 1 /* Define if you have unsetenv */ #cmakedefine HAVE_UNSETENV 1 /* Define if you have the unsetenv prototype */ #cmakedefine HAVE_UNSETENV_PROTO 1 /* Define if you have usleep */ #cmakedefine HAVE_USLEEP 1 /* Define if you have the usleep prototype */ #cmakedefine HAVE_USLEEP_PROTO 1 /* Define to 1 if you have the `vsnprintf' function. */ #cmakedefine HAVE_VSNPRINTF 1 /* KDE's default home directory */ #cmakedefine KDE_DEFAULT_HOME "${KDE_DEFAULT_HOME}" /* KDE's binaries directory */ #define KDE_BINDIR "${KDE_INSTALL_BINDIR}" /* KDE's configuration directory */ #define KDE_CONFDIR "${KDE_INSTALL_CONFDIR}" /* KDE's static data directory */ #define KDE_DATADIR "${KDE_INSTALL_DATADIR}" /* Define where your java executable is */ #undef PATH_JAVA /* Define to 1 if you can safely include both and . */ #cmakedefine TIME_WITH_SYS_TIME 1 /* X binaries directory */ #cmakedefine XBINDIR "${XBINDIR}" /* X libraries directory */ #cmakedefine XLIBDIR "${XLIBDIR}" /* Number of bits in a file offset, on hosts where this is settable. */ #define _FILE_OFFSET_BITS 64 /* * On HP-UX, the declaration of vsnprintf() is needed every time ! */ /* type to use in place of socklen_t if not defined */ #define kde_socklen_t socklen_t /** place where plasma-frameworks things are installed */ #define PLASMA_RELATIVE_DATA_INSTALL_DIR "@PLASMA_RELATIVE_DATA_INSTALL_DIR@" + +#cmakedefine PLASMA_SYSTEMD_BOOT 1 diff --git a/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop b/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop index 289eb5ec4..98dfc7edf 100644 --- a/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop +++ b/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop @@ -1,39 +1,40 @@ [Desktop Entry] Exec=gmenudbusmenuproxy Name=GMenuDBusMenuProxy Name[ast]=GMenuDBusMenuProxy Name[ca]=GMenuDBusMenuProxy Name[ca@valencia]=GMenuDBusMenuProxy Name[da]=GMenuDBusMenuProxy Name[de]=GMenuDBusMenuProxy Name[el]=GMenuDBusMenuProxy Name[en_GB]=GMenuDBusMenuProxy Name[es]=GMenuDBusMenuProxy Name[et]=GMenuDBusMenuProxy Name[eu]=GMenuDBusMenuProxy Name[fi]=GMenuDBusMenuProxy Name[fr]=GMenuDBusMenuProxy Name[gl]=Proxy de menú por D-Bus para GMenu. Name[hu]=GMenuDBusMenuProxy Name[id]=GMenuDBusMenuProxy Name[it]=GMenuDBusMenuProxy Name[ko]=GMenuDBusMenuProxy Name[lt]=GMenuDBusMenuProxy Name[nl]=GMenuDBusMenuProxy Name[nn]=GMenuDBusMenuProxy Name[pa]=GMenuDBusMenuProxy Name[pl]=GMenuDBusMenuProxy Name[pt]=GMenuDBusMenuProxy Name[pt_BR]=GMenuDBusMenuProxy Name[ru]=GMenuDBusMenuProxy Name[sk]=GMenuDBusMenuProxy Name[sl]=GMenuDBusMenuProxy Name[sv]=GMenuDBusMenuProxy Name[uk]=Проксі-меню GMenu D-Bus Name[x-test]=xxGMenuDBusMenuProxyxx Name[zh_CN]=GMenuDBusMenuProxy Name[zh_TW]=GMenuDBusMenuProxy Type=Application X-KDE-StartupNotify=false OnlyShowIn=KDE; X-KDE-autostart-phase=1 +X-systemd-hidden=true diff --git a/gmenu-dbusmenu-proxy/plasma-gmenudbusproxy.service.in b/gmenu-dbusmenu-proxy/plasma-gmenudbusproxy.service.in new file mode 100644 index 000000000..c33191b77 --- /dev/null +++ b/gmenu-dbusmenu-proxy/plasma-gmenudbusproxy.service.in @@ -0,0 +1,13 @@ +[Unit] +Description=Proxies GTK DBus menus to a Plasma readable format + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/gmenudbusmenuproxy +Restart=on-failure +KillMode=process +Type=simple +Slice=background.slice +TimeoutSec=5sec + +[Install] +WantedBy=plasma-workspace.target diff --git a/krunner/CMakeLists.txt b/krunner/CMakeLists.txt index 2ad1f07f2..a94c078da 100644 --- a/krunner/CMakeLists.txt +++ b/krunner/CMakeLists.txt @@ -1,44 +1,47 @@ set(krunner_SRCS main.cpp view.cpp ) set(krunner_dbusAppXML dbus/org.kde.krunner.App.xml) qt5_add_dbus_adaptor(krunner_SRCS ${krunner_dbusAppXML} view.h View) configure_file(dbus/org.kde.krunner.service.in ${CMAKE_CURRENT_BINARY_DIR}/org.kde.krunner.service) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.krunner.service DESTINATION ${KDE_INSTALL_DBUSSERVICEDIR}) add_executable(krunner ${krunner_SRCS}) target_link_libraries(krunner Qt5::Quick Qt5::Widgets KF5::Declarative KF5::I18n KF5::PlasmaQuick KF5::DBusAddons KF5::Crash KF5::WaylandClient KF5::QuickAddons PW::KWorkspace ) target_compile_definitions(krunner PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") install(TARGETS krunner ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${krunner_dbusAppXML} DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} ) configure_file(krunner.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/krunner.desktop @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/krunner.desktop DESTINATION ${DATA_INSTALL_DIR}/kglobalaccel) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KRunnerAppDBusInterface") configure_package_config_file(KRunnerAppDBusInterfaceConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/KRunnerAppDBusInterfaceConfig.cmake" PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KRunnerAppDBusInterfaceConfig.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) +ecm_install_configured_files(TEMPLATES plasma-krunner.service.in @ONLY DESTINATION + ${SYSTEMD_USER_UNIT_INSTALL_DIR}) + add_subdirectory(update) diff --git a/krunner/dbus/org.kde.krunner.service.in b/krunner/dbus/org.kde.krunner.service.in index 46a2d1e79..ad6f0234f 100644 --- a/krunner/dbus/org.kde.krunner.service.in +++ b/krunner/dbus/org.kde.krunner.service.in @@ -1,3 +1,4 @@ [D-BUS Service] Name=org.kde.krunner Exec=@KDE_INSTALL_FULL_BINDIR@/krunner +SystemdService=krunner.service diff --git a/krunner/plasma-krunner.service.in b/krunner/plasma-krunner.service.in new file mode 100644 index 000000000..e8e91128b --- /dev/null +++ b/krunner/plasma-krunner.service.in @@ -0,0 +1,10 @@ +[Unit] +Description=KRunner + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/krunner +KillMode=process +Type=dbus +BusName=org.kde.krunner +TimeoutSec=5sec +Slice=background.slice diff --git a/ksmserver/CMakeLists.txt b/ksmserver/CMakeLists.txt index 68bc5831f..bba96413f 100644 --- a/ksmserver/CMakeLists.txt +++ b/ksmserver/CMakeLists.txt @@ -1,73 +1,75 @@ add_definitions(-DTRANSLATION_DOMAIN=\"ksmserver\") check_library_exists("${X11_ICE_LIB}" _IceTransNoListen "" HAVE__ICETRANSNOLISTEN) configure_file(config-ksmserver.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksmserver.h) add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII") add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ########### next target ############### set(ksmserver_SRCS main.cpp server.cpp legacy.cpp logout.cpp client.cpp ) ecm_qt_declare_logging_category(ksmserver_SRCS HEADER ksmserver_debug.h IDENTIFIER KSMSERVER CATEGORY_NAME org.kde.kf5.ksmserver) qt5_add_dbus_adaptor( ksmserver_SRCS org.kde.KSMServerInterface.xml server.h KSMServer ) qt5_add_dbus_interface( ksmserver_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface ) qt5_add_dbus_interface( ksmserver_SRCS org.kde.LogoutPrompt.xml logoutprompt_interface) qt5_add_dbus_interface( ksmserver_SRCS org.kde.KWin.Session.xml kwinsession_interface) set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) qt5_add_dbus_interface( ksmserver_SRCS ${klauncher_xml} klauncher_interface ) qt5_add_dbus_interface( ksmserver_SRCS ../startkde/plasma-session/org.kde.Startup.xml startup_interface ) qt5_add_dbus_interface( ksmserver_SRCS ../startkde/plasma-shutdown/org.kde.Shutdown.xml shutdown_interface ) add_executable(ksmserver ${ksmserver_SRCS}) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KSMServerDBusInterface") configure_package_config_file(KSMServerDBusInterfaceConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KSMServerDBusInterfaceConfig.cmake PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) target_link_libraries(ksmserver PW::KScreenLocker PW::KWorkspace KF5::XmlGui KF5::GlobalAccel KF5::I18n KF5::KIOCore KF5::KIOGui ${X11_LIBRARIES} ${X11_Xrender_LIB} Qt5::X11Extras KF5::Solid Qt5::Quick KF5::Declarative KF5::DBusAddons KF5::Notifications KF5::Package KF5::WindowSystem Qt5::Concurrent ) install(TARGETS ksmserver ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KSMServerDBusInterfaceConfig.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) ########### install files ############### install( FILES org.kde.KSMServerInterface.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}) + +ecm_install_configured_files(TEMPLATES plasma-ksmserver.service.in DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) diff --git a/ksmserver/plasma-ksmserver.service.in b/ksmserver/plasma-ksmserver.service.in new file mode 100644 index 000000000..199f0a57c --- /dev/null +++ b/ksmserver/plasma-ksmserver.service.in @@ -0,0 +1,13 @@ +[Unit] +Description=KDE Session Management Server +Wants=plasma-kcminit.service + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/ksmserver +# This magic minus sign means don't fail if exit code is non-zero... +ExecStartPost=-@QtBinariesDir@/qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage ksmserver +BusName=org.kde.ksmserver +Slice=session.slice + +[Install] +WantedBy=plasma-core.target diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp index d7e24a750..f4cd6b49f 100644 --- a/ksmserver/server.cpp +++ b/ksmserver/server.cpp @@ -1,1142 +1,1144 @@ /***************************************************************** ksmserver - the KDE session management server Copyright 2000 Matthias Ettrich Copyright 2005 Lubos Lunak relatively small extensions by Oswald Buddenhagen some code taken from the dcopserver (part of the KDE libraries), which is Copyright 1999 Matthias Ettrich Copyright 1999 Preston Brown Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************/ #include "server.h" #include "global.h" #include "client.h" #include "ksmserver_debug.h" #include "ksmserverinterfaceadaptor.h" #include "klocalizedstring.h" #include "kglobalaccel.h" #include #include // HAVE_LIMITS_H #include #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIMITS_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kscreenlocker_interface.h" #include "kwinsession_interface.h" +#include "../config-workspace.h" + KSMServer* the_server = nullptr; KSMServer* KSMServer::self() { return the_server; } /*! Utility function to execute a command on the local machine. Used * to restart applications. */ void KSMServer::startApplication( const QStringList& cmd, const QString& clientMachine, const QString& userId) { QStringList command = cmd; if ( command.isEmpty() ) return; if ( !userId.isEmpty()) { struct passwd* pw = getpwuid( getuid()); if( pw != nullptr && userId != QString::fromLocal8Bit( pw->pw_name )) { command.prepend( QStringLiteral("--") ); command.prepend( userId ); command.prepend( QStringLiteral("-u") ); command.prepend( QStandardPaths::findExecutable(QStringLiteral("kdesu"))); } } if ( !clientMachine.isEmpty() && clientMachine != QLatin1String("localhost") ) { command.prepend( clientMachine ); command.prepend( xonCommand ); // "xon" by default } const QString app = command.takeFirst(); const QStringList argList = command; auto *job = new KIO::CommandLauncherJob(app, argList); job->start(); } /*! Utility function to execute a command on the local machine. Used * to discard session data */ void KSMServer::executeCommand( const QStringList& command ) { if ( command.isEmpty() ) return; KProcess::execute( command ); } IceAuthDataEntry *authDataEntries = nullptr; static QTemporaryFile *remTempFile = nullptr; static IceListenObj *listenObjs = nullptr; int numTransports = 0; static bool only_local = 0; static Bool HostBasedAuthProc ( char* /*hostname*/) { if (only_local) return true; else return false; } Status KSMRegisterClientProc ( SmsConn /* smsConn */, SmPointer managerData, char * previousId ) { KSMClient* client = (KSMClient*) managerData; client->registerClient( previousId ); return 1; } void KSMInteractRequestProc ( SmsConn /* smsConn */, SmPointer managerData, int dialogType ) { the_server->interactRequest( (KSMClient*) managerData, dialogType ); } void KSMInteractDoneProc ( SmsConn /* smsConn */, SmPointer managerData, Bool cancelShutdown ) { the_server->interactDone( (KSMClient*) managerData, cancelShutdown ); } void KSMSaveYourselfRequestProc ( SmsConn smsConn , SmPointer /* managerData */, int saveType, Bool shutdown, int interactStyle, Bool fast, Bool global ) { if ( shutdown ) { the_server->shutdown( fast ? KWorkSpace::ShutdownConfirmNo : KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeDefault, KWorkSpace::ShutdownModeDefault ); } else if ( !global ) { SmsSaveYourself( smsConn, saveType, false, interactStyle, fast ); SmsSaveComplete( smsConn ); } // else checkpoint only, ksmserver does not yet support this // mode. Will come for KDE 3.1 } void KSMSaveYourselfPhase2RequestProc ( SmsConn /* smsConn */, SmPointer managerData ) { the_server->phase2Request( (KSMClient*) managerData ); } void KSMSaveYourselfDoneProc ( SmsConn /* smsConn */, SmPointer managerData, Bool success ) { the_server->saveYourselfDone( (KSMClient*) managerData, success ); } void KSMCloseConnectionProc ( SmsConn smsConn, SmPointer managerData, int count, char ** reasonMsgs ) { the_server->deleteClient( ( KSMClient* ) managerData ); if ( count ) SmFreeReasons( count, reasonMsgs ); IceConn iceConn = SmsGetIceConnection( smsConn ); SmsCleanUp( smsConn ); IceSetShutdownNegotiation (iceConn, False); IceCloseConnection( iceConn ); } void KSMSetPropertiesProc ( SmsConn /* smsConn */, SmPointer managerData, int numProps, SmProp ** props ) { KSMClient* client = ( KSMClient* ) managerData; for ( int i = 0; i < numProps; i++ ) { SmProp *p = client->property( props[i]->name ); if ( p ) { client->properties.removeAll( p ); SmFreeProperty( p ); } client->properties.append( props[i] ); } if ( numProps ) free( props ); } void KSMDeletePropertiesProc ( SmsConn /* smsConn */, SmPointer managerData, int numProps, char ** propNames ) { KSMClient* client = ( KSMClient* ) managerData; for ( int i = 0; i < numProps; i++ ) { SmProp *p = client->property( propNames[i] ); if ( p ) { client->properties.removeAll( p ); SmFreeProperty( p ); } } } void KSMGetPropertiesProc ( SmsConn smsConn, SmPointer managerData ) { KSMClient* client = ( KSMClient* ) managerData; SmProp** props = new SmProp*[client->properties.count()]; int i = 0; foreach( SmProp *prop, client->properties ) props[i++] = prop; SmsReturnProperties( smsConn, i, props ); delete [] props; } class KSMListener : public QSocketNotifier { public: KSMListener( IceListenObj obj ) : QSocketNotifier( IceGetListenConnectionNumber( obj ), QSocketNotifier::Read ) { listenObj = obj; } IceListenObj listenObj; }; class KSMConnection : public QSocketNotifier { public: KSMConnection( IceConn conn ) : QSocketNotifier( IceConnectionNumber( conn ), QSocketNotifier::Read ) { iceConn = conn; } IceConn iceConn; }; /* for printing hex digits */ static void fprintfhex (FILE *fp, unsigned int len, char *cp) { static const char hexchars[] = "0123456789abcdef"; for (; len > 0; len--, cp++) { unsigned char s = *cp; putc(hexchars[s >> 4], fp); putc(hexchars[s & 0x0f], fp); } } /* * We use temporary files which contain commands to add/remove entries from * the .ICEauthority file. */ static void write_iceauth (FILE *addfp, FILE *removefp, IceAuthDataEntry *entry) { fprintf (addfp, "add %s \"\" %s %s ", entry->protocol_name, entry->network_id, entry->auth_name); fprintfhex (addfp, entry->auth_data_length, entry->auth_data); fprintf (addfp, "\n"); fprintf (removefp, "remove protoname=%s protodata=\"\" netid=%s authname=%s\n", entry->protocol_name, entry->network_id, entry->auth_name); } #define MAGIC_COOKIE_LEN 16 Status SetAuthentication_local (int count, IceListenObj *listenObjs) { int i; for (i = 0; i < count; i ++) { char *prot = IceGetListenConnectionString(listenObjs[i]); if (!prot) continue; char *host = strchr(prot, '/'); char *sock = nullptr; if (host) { *host=0; host++; sock = strchr(host, ':'); if (sock) { *sock = 0; sock++; } } qCDebug(KSMSERVER) << "KSMServer: SetAProc_loc: conn " << (unsigned)i << ", prot=" << prot << ", file=" << sock; if (sock && !strcmp(prot, "local")) { chmod(sock, 0700); } IceSetHostBasedAuthProc (listenObjs[i], HostBasedAuthProc); free(prot); } return 1; } Status SetAuthentication (int count, IceListenObj *listenObjs, IceAuthDataEntry **authDataEntries) { QTemporaryFile addTempFile; remTempFile = new QTemporaryFile; if (!addTempFile.open() || !remTempFile->open()) return 0; if ((*authDataEntries = (IceAuthDataEntry *) malloc ( count * 2 * sizeof (IceAuthDataEntry))) == nullptr) return 0; FILE *addAuthFile = fopen(QFile::encodeName(addTempFile.fileName()).constData(), "r+"); FILE *remAuthFile = fopen(QFile::encodeName(remTempFile->fileName()).constData(), "r+"); for (int i = 0; i < numTransports * 2; i += 2) { (*authDataEntries)[i].network_id = IceGetListenConnectionString (listenObjs[i/2]); (*authDataEntries)[i].protocol_name = (char *) "ICE"; (*authDataEntries)[i].auth_name = (char *) "MIT-MAGIC-COOKIE-1"; (*authDataEntries)[i].auth_data = IceGenerateMagicCookie (MAGIC_COOKIE_LEN); (*authDataEntries)[i].auth_data_length = MAGIC_COOKIE_LEN; (*authDataEntries)[i+1].network_id = IceGetListenConnectionString (listenObjs[i/2]); (*authDataEntries)[i+1].protocol_name = (char *) "XSMP"; (*authDataEntries)[i+1].auth_name = (char *) "MIT-MAGIC-COOKIE-1"; (*authDataEntries)[i+1].auth_data = IceGenerateMagicCookie (MAGIC_COOKIE_LEN); (*authDataEntries)[i+1].auth_data_length = MAGIC_COOKIE_LEN; write_iceauth (addAuthFile, remAuthFile, &(*authDataEntries)[i]); write_iceauth (addAuthFile, remAuthFile, &(*authDataEntries)[i+1]); IceSetPaAuthData (2, &(*authDataEntries)[i]); IceSetHostBasedAuthProc (listenObjs[i/2], HostBasedAuthProc); } fclose(addAuthFile); fclose(remAuthFile); QString iceAuth = QStandardPaths::findExecutable(QStringLiteral("iceauth")); if (iceAuth.isEmpty()) { qCWarning(KSMSERVER, "KSMServer: could not find iceauth"); return 0; } KProcess p; p << iceAuth << QStringLiteral("source") << addTempFile.fileName(); p.execute(); return (1); } /* * Free up authentication data. */ void FreeAuthenticationData(int count, IceAuthDataEntry *authDataEntries) { /* Each transport has entries for ICE and XSMP */ if (only_local) return; for (int i = 0; i < count * 2; i++) { free (authDataEntries[i].network_id); free (authDataEntries[i].auth_data); } free (authDataEntries); QString iceAuth = QStandardPaths::findExecutable(QStringLiteral("iceauth")); if (iceAuth.isEmpty()) { qCWarning(KSMSERVER, "KSMServer: could not find iceauth"); return; } if (remTempFile) { KProcess p; p << iceAuth << QStringLiteral("source") << remTempFile->fileName(); p.execute(); } delete remTempFile; remTempFile = nullptr; } static int Xio_ErrorHandler( Display * ) { qCWarning(KSMSERVER, "ksmserver: Fatal IO error: client killed"); // Don't do anything that might require the X connection if (the_server) { KSMServer *server = the_server; the_server = nullptr; server->cleanUp(); // Don't delete server!! } exit(0); // Don't report error, it's not our fault. return 0; // Bogus return value, notreached } void KSMServer::setupXIOErrorHandler() { XSetIOErrorHandler(Xio_ErrorHandler); } static int wake_up_socket = -1; static void sighandler(int sig) { if (sig == SIGHUP) { signal(SIGHUP, sighandler); return; } char ch = 0; (void)::write(wake_up_socket, &ch, 1); } void KSMWatchProc ( IceConn iceConn, IcePointer client_data, Bool opening, IcePointer* watch_data) { KSMServer* ds = ( KSMServer*) client_data; if (opening) { *watch_data = (IcePointer) ds->watchConnection( iceConn ); } else { ds->removeConnection( (KSMConnection*) *watch_data ); } } static Status KSMNewClientProc ( SmsConn conn, SmPointer manager_data, unsigned long* mask_ret, SmsCallbacks* cb, char** failure_reason_ret) { *failure_reason_ret = nullptr; void* client = ((KSMServer*) manager_data )->newClient( conn ); cb->register_client.callback = KSMRegisterClientProc; cb->register_client.manager_data = client; cb->interact_request.callback = KSMInteractRequestProc; cb->interact_request.manager_data = client; cb->interact_done.callback = KSMInteractDoneProc; cb->interact_done.manager_data = client; cb->save_yourself_request.callback = KSMSaveYourselfRequestProc; cb->save_yourself_request.manager_data = client; cb->save_yourself_phase2_request.callback = KSMSaveYourselfPhase2RequestProc; cb->save_yourself_phase2_request.manager_data = client; cb->save_yourself_done.callback = KSMSaveYourselfDoneProc; cb->save_yourself_done.manager_data = client; cb->close_connection.callback = KSMCloseConnectionProc; cb->close_connection.manager_data = client; cb->set_properties.callback = KSMSetPropertiesProc; cb->set_properties.manager_data = client; cb->delete_properties.callback = KSMDeletePropertiesProc; cb->delete_properties.manager_data = client; cb->get_properties.callback = KSMGetPropertiesProc; cb->get_properties.manager_data = client; *mask_ret = SmsRegisterClientProcMask | SmsInteractRequestProcMask | SmsInteractDoneProcMask | SmsSaveYourselfRequestProcMask | SmsSaveYourselfP2RequestProcMask | SmsSaveYourselfDoneProcMask | SmsCloseConnectionProcMask | SmsSetPropertiesProcMask | SmsDeletePropertiesProcMask | SmsGetPropertiesProcMask; return 1; } #ifdef HAVE__ICETRANSNOLISTEN extern "C" int _IceTransNoListen(const char * protocol); #endif KSMServer::KSMServer(InitFlags flags) : sessionGroup( QStringLiteral( "" ) ) , m_kwinInterface(new OrgKdeKWinSessionInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Session"), QDBusConnection::sessionBus(), this)) , sockets{ -1, -1 } { if (!flags.testFlag(InitFlag::NoLockScreen)) { ScreenLocker::KSldApp::self()->initialize(); if (flags.testFlag(InitFlag::ImmediateLockScreen)) { ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); } } if(::socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sockets) != 0) qFatal("Could not create socket pair, error %d (%s)", errno, strerror(errno)); wake_up_socket = sockets[0]; QSocketNotifier* n = new QSocketNotifier(sockets[1], QSocketNotifier::Read, this); qApp->connect(n, &QSocketNotifier::activated, &QApplication::quit); new KSMServerInterfaceAdaptor( this ); QDBusConnection::sessionBus().registerObject(QStringLiteral("/KSMServer"), this); the_server = this; clean = false; state = Idle; saveSession = false; KConfigGroup config(KSharedConfig::openConfig(), "General"); clientInteracting = nullptr; xonCommand = config.readEntry( "xonCommand", "xon" ); only_local = flags.testFlag(InitFlag::OnlyLocal); #ifdef HAVE__ICETRANSNOLISTEN if (only_local) _IceTransNoListen("tcp"); #else only_local = false; #endif char errormsg[256]; if (!SmsInitialize ( (char*) KSMVendorString, (char*) KSMReleaseString, KSMNewClientProc, (SmPointer) this, HostBasedAuthProc, 256, errormsg ) ) { qCWarning(KSMSERVER, "KSMServer: could not register XSM protocol"); } if (!IceListenForConnections (&numTransports, &listenObjs, 256, errormsg)) { qCWarning(KSMSERVER, "KSMServer: Error listening for connections: %s", errormsg); qCWarning(KSMSERVER, "KSMServer: Aborting."); exit(1); } { // publish available transports. QByteArray fName = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + QDir::separator() + QStringLiteral("KSMserver")); qCDebug(KSMSERVER) << fName; QString display = QString::fromLocal8Bit(::getenv("DISPLAY")); // strip the screen number from the display display.remove(QRegularExpression(QStringLiteral("\\.[0-9]+$"))); int i; while( (i = display.indexOf(QLatin1Char(':'))) >= 0) display[i] = '_'; while( (i = display.indexOf(QLatin1Char('/'))) >= 0) display[i] = '_'; fName += '_'+display.toLocal8Bit(); FILE *f; f = ::fopen(fName.data(), "w+"); if (!f) { qCWarning(KSMSERVER, "KSMServer: cannot open %s: %s", fName.data(), strerror(errno)); qCWarning(KSMSERVER, "KSMServer: Aborting."); exit(1); } char* session_manager = IceComposeNetworkIdList(numTransports, listenObjs); fprintf(f, "%s\n%i\n", session_manager, getpid()); fclose(f); setenv( "SESSION_MANAGER", session_manager, true ); // Pass env. var to kdeinit. org::kde::KLauncher klauncher( QStringLiteral( "org.kde.klauncher5" ), QStringLiteral( "/KLauncher" ), QDBusConnection::sessionBus()); klauncher.setLaunchEnv( QStringLiteral( "SESSION_MANAGER" ), QString::fromLocal8Bit( (const char*) session_manager ) ); org::kde::Startup startup(QStringLiteral("org.kde.Startup"), QStringLiteral("/Startup"), QDBusConnection::sessionBus()); startup.updateLaunchEnv( QStringLiteral( "SESSION_MANAGER" ), QString::fromLocal8Bit( (const char*) session_manager ) ); free(session_manager); } if (only_local) { if (!SetAuthentication_local(numTransports, listenObjs)) qFatal("KSMSERVER: authentication setup failed."); } else { if (!SetAuthentication(numTransports, listenObjs, &authDataEntries)) qFatal("KSMSERVER: authentication setup failed."); } IceAddConnectionWatch (KSMWatchProc, (IcePointer) this); KSMListener* con; for ( int i = 0; i < numTransports; i++) { fcntl( IceGetListenConnectionNumber( listenObjs[i] ), F_SETFD, FD_CLOEXEC ); con = new KSMListener( listenObjs[i] ); listener.append( con ); connect(con, &KSMListener::activated, this, &KSMServer::newConnection); } signal(SIGHUP, sighandler); signal(SIGTERM, sighandler); signal(SIGINT, sighandler); signal(SIGPIPE, SIG_IGN); connect(&protectionTimer, &QTimer::timeout, this, &KSMServer::protectionTimeout); connect(&restoreTimer, &QTimer::timeout, this, &KSMServer::tryRestoreNext); connect(qApp, &QApplication::aboutToQuit, this, &KSMServer::cleanUp); setupXIOErrorHandler(); } KSMServer::~KSMServer() { qDeleteAll( listener ); the_server = nullptr; cleanUp(); } void KSMServer::cleanUp() { if (clean) return; clean = true; IceFreeListenObjs (numTransports, listenObjs); wake_up_socket = -1; ::close(sockets[1]); ::close(sockets[0]); sockets[0] = -1; sockets[1] = -1; QByteArray fName = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + QLatin1Char('/') + QStringLiteral("KSMserver")); QString display = QString::fromLocal8Bit(::getenv("DISPLAY")); // strip the screen number from the display display.remove(QRegularExpression(QStringLiteral("\\.[0-9]+$"))); int i; while( (i = display.indexOf(QLatin1Char(':'))) >= 0) display[i] = '_'; while( (i = display.indexOf(QLatin1Char('/'))) >= 0) display[i] = '_'; fName += '_'+display.toLocal8Bit(); ::unlink(fName.data()); FreeAuthenticationData(numTransports, authDataEntries); signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); } void* KSMServer::watchConnection( IceConn iceConn ) { KSMConnection* conn = new KSMConnection( iceConn ); connect(conn, &KSMConnection::activated, this, &KSMServer::processData); return (void*) conn; } void KSMServer::removeConnection( KSMConnection* conn ) { delete conn; } /*! Called from our IceIoErrorHandler */ void KSMServer::ioError( IceConn /*iceConn*/ ) { } void KSMServer::processData( int /*socket*/ ) { IceConn iceConn = ((KSMConnection*)sender())->iceConn; IceProcessMessagesStatus status = IceProcessMessages( iceConn, nullptr, nullptr ); if ( status == IceProcessMessagesIOError ) { IceSetShutdownNegotiation( iceConn, False ); QList::iterator it = clients.begin(); QList::iterator const itEnd = clients.end(); while ( ( it != itEnd ) && *it && ( SmsGetIceConnection( ( *it )->connection() ) != iceConn ) ) ++it; if ( ( it != itEnd ) && *it ) { SmsConn smsConn = (*it)->connection(); deleteClient( *it ); SmsCleanUp( smsConn ); } (void) IceCloseConnection( iceConn ); } } KSMClient* KSMServer::newClient( SmsConn conn ) { KSMClient* client = new KSMClient( conn ); clients.append( client ); return client; } void KSMServer::deleteClient( KSMClient* client ) { if ( !clients.contains( client ) ) // paranoia return; clients.removeAll( client ); clientsToKill.removeAll( client ); clientsToSave.removeAll( client ); if ( client == clientInteracting ) { clientInteracting = nullptr; handlePendingInteractions(); } delete client; if ( state == Shutdown || state == Checkpoint || state == ClosingSubSession ) completeShutdownOrCheckpoint(); if ( state == Killing ) completeKilling(); else if ( state == KillingSubSession ) completeKillingSubSession(); } void KSMServer::newConnection( int /*socket*/ ) { IceAcceptStatus status; IceConn iceConn = IceAcceptConnection( ((KSMListener*)sender())->listenObj, &status); if( iceConn == nullptr ) return; IceSetShutdownNegotiation( iceConn, False ); IceConnectStatus cstatus; while ((cstatus = IceConnectionStatus (iceConn))==IceConnectPending) { (void) IceProcessMessages( iceConn, nullptr, nullptr ); } if (cstatus != IceConnectAccepted) { if (cstatus == IceConnectIOError) qCDebug(KSMSERVER) << "IO error opening ICE Connection!"; else qCDebug(KSMSERVER) << "ICE Connection rejected!"; (void )IceCloseConnection (iceConn); return; } // don't leak the fd fcntl( IceConnectionNumber(iceConn), F_SETFD, FD_CLOEXEC ); } QString KSMServer::currentSession() { if ( sessionGroup.startsWith( QLatin1String( "Session: " ) ) ) return sessionGroup.mid( 9 ); return QStringLiteral( "" ); // empty, not null, since used for KConfig::setGroup // TODO does this comment make any sense? } void KSMServer::discardSession() { KConfigGroup config(KSharedConfig::openConfig(), sessionGroup ); int count = config.readEntry( "count", 0 ); foreach ( KSMClient *c, clients ) { QStringList discardCommand = c->discardCommand(); if ( discardCommand.isEmpty()) continue; // check that non of the old clients used the exactly same // discardCommand before we execute it. This used to be the // case up to KDE and Qt < 3.1 int i = 1; while ( i <= count && config.readPathEntry( QStringLiteral("discardCommand") + QString::number(i), QStringList() ) != discardCommand ) i++; if ( i <= count ) executeCommand( discardCommand ); } } void KSMServer::storeSession() { KSharedConfig::Ptr config = KSharedConfig::openConfig(); config->reparseConfiguration(); // config may have changed in the KControl module KConfigGroup generalGroup(config, "General"); excludeApps = generalGroup.readEntry( "excludeApps" ).toLower() .split( QRegularExpression( QStringLiteral("[,:]") ), QString::SkipEmptyParts ); KConfigGroup configSessionGroup(config, sessionGroup); int count = configSessionGroup.readEntry( "count", 0 ); for ( int i = 1; i <= count; i++ ) { QStringList discardCommand = configSessionGroup.readPathEntry( QLatin1String("discardCommand") + QString::number(i), QStringList() ); if ( discardCommand.isEmpty()) continue; // check that non of the new clients uses the exactly same // discardCommand before we execute it. This used to be the // case up to KDE and Qt < 3.1 QList::iterator it = clients.begin(); QList::iterator const itEnd = clients.end(); while ( ( it != itEnd ) && *it && (discardCommand != ( *it )->discardCommand() ) ) ++it; if ( ( it != itEnd ) && *it ) continue; executeCommand( discardCommand ); } config->deleteGroup( sessionGroup ); //### does not work with global config object... KConfigGroup cg( config, sessionGroup); count = 0; // Tell kwin to save its state auto reply = m_kwinInterface->finishSaveSession(currentSession()); reply.waitForFinished(); // boo! foreach ( KSMClient *c, clients ) { int restartHint = c->restartStyleHint(); if (restartHint == SmRestartNever) continue; QString program = c->program(); QStringList restartCommand = c->restartCommand(); if (program.isEmpty() && restartCommand.isEmpty()) continue; if (state == ClosingSubSession && ! clientsToSave.contains(c)) continue; // 'program' might be (mostly) fullpath, or (sometimes) just the name. // 'name' is just the name. QFileInfo info(program); const QString& name = info.fileName(); if ( excludeApps.contains(program.toLower()) || excludeApps.contains(name.toLower()) ) { continue; } count++; QString n = QString::number(count); cg.writeEntry( QStringLiteral("program")+n, program ); cg.writeEntry( QStringLiteral("clientId")+n, c->clientId() ); cg.writeEntry( QStringLiteral("restartCommand")+n, restartCommand ); cg.writePathEntry( QStringLiteral("discardCommand")+n, c->discardCommand() ); cg.writeEntry( QStringLiteral("restartStyleHint")+n, restartHint ); cg.writeEntry( QStringLiteral("userId")+n, c->userId() ); } cg.writeEntry( "count", count ); KConfigGroup cg2( config, "General"); storeLegacySession(config.data()); config->sync(); } QStringList KSMServer::sessionList() { QStringList sessions( QStringLiteral( "default" ) ); KSharedConfig::Ptr config = KSharedConfig::openConfig(); const QStringList groups = config->groupList(); for ( QStringList::ConstIterator it = groups.constBegin(); it != groups.constEnd(); ++it ) if ( (*it).startsWith( QLatin1String( "Session: " ) ) ) sessions << (*it).mid( 9 ); return sessions; } bool KSMServer::defaultSession() const { return sessionGroup.isEmpty(); } void KSMServer::setupShortcuts() { if (KAuthorized::authorize( QStringLiteral( "logout" ))) { KActionCollection* actionCollection = new KActionCollection(this); actionCollection->setComponentDisplayName(i18n("Session Management")); QAction* a; a = actionCollection->addAction(QStringLiteral("Log Out")); a->setText(i18n("Log Out")); KGlobalAccel::self()->setShortcut(a, QList() << Qt::ALT+Qt::CTRL+Qt::Key_Delete); connect(a, &QAction::triggered, this, &KSMServer::defaultLogout); a = actionCollection->addAction(QStringLiteral("Log Out Without Confirmation")); a->setText(i18n("Log Out Without Confirmation")); KGlobalAccel::self()->setShortcut(a, QList() << Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Delete); connect(a, &QAction::triggered, this, &KSMServer::logoutWithoutConfirmation); a = actionCollection->addAction(QStringLiteral("Halt Without Confirmation")); a->setText(i18n("Halt Without Confirmation")); KGlobalAccel::self()->setShortcut(a, QList() << Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown); connect(a, &QAction::triggered, this, &KSMServer::haltWithoutConfirmation); a = actionCollection->addAction(QStringLiteral("Reboot Without Confirmation")); a->setText(i18n("Reboot Without Confirmation")); KGlobalAccel::self()->setShortcut(a, QList() << Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageUp); connect(a, &QAction::triggered, this, &KSMServer::rebootWithoutConfirmation); } } /*! Restores the previous session. */ void KSMServer::restoreSession( const QString &sessionName ) { if( state != Idle ) return; #ifdef KSMSERVER_STARTUP_DEBUG1 t.start(); #endif state = RestoringWMSession; qCDebug(KSMSERVER) << "KSMServer::restoreSession " << sessionName; KSharedConfig::Ptr config = KSharedConfig::openConfig(); sessionGroup = QLatin1String("Session: ") + sessionName; KConfigGroup configSessionGroup( config, sessionGroup); int count = configSessionGroup.readEntry( "count", 0 ); appsToStart = count; auto reply = m_kwinInterface->loadSession(sessionName); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); if (state == RestoringWMSession) { state = Idle; } }); } /*! Starts the default session. */ void KSMServer::startDefaultSession() { if( state != Idle ) return; state = RestoringWMSession; #ifdef KSMSERVER_STARTUP_DEBUG1 t.start(); #endif sessionGroup = QString(); } void KSMServer::restoreSession() { Q_ASSERT(calledFromDBus()); if (defaultSession()) { state = KSMServer::Idle; return; } setDelayedReply(true); m_restoreSessionCall = message(); restoreLegacySession(KSharedConfig::openConfig().data()); lastAppStarted = 0; lastIdStarted.clear(); state = KSMServer::Restoring; connect(this, &KSMServer::sessionRestored, this, [this]() { auto reply = m_restoreSessionCall.createReply(); QDBusConnection::sessionBus().send(reply); m_restoreSessionCall = QDBusMessage(); }); tryRestoreNext(); } void KSMServer::restoreSubSession( const QString& name ) { sessionGroup = QStringLiteral( "SubSession: " ) + name; KConfigGroup configSessionGroup( KSharedConfig::openConfig(), sessionGroup); int count = configSessionGroup.readEntry( "count", 0 ); appsToStart = count; lastAppStarted = 0; lastIdStarted.clear(); state = RestoringSubSession; tryRestoreNext(); } void KSMServer::clientRegistered( const char* previousId ) { if ( previousId && lastIdStarted == QString::fromLocal8Bit( previousId ) ) tryRestoreNext(); } void KSMServer::tryRestoreNext() { if( state != Restoring && state != RestoringSubSession ) return; restoreTimer.stop(); KConfigGroup config(KSharedConfig::openConfig(), sessionGroup ); while ( lastAppStarted < appsToStart ) { lastAppStarted++; QString n = QString::number(lastAppStarted); QString clientId = config.readEntry( QLatin1String("clientId")+n, QString() ); bool alreadyStarted = false; foreach ( KSMClient *c, clients ) { if ( QString::fromLocal8Bit( c->clientId() ) == clientId ) { alreadyStarted = true; break; } } if ( alreadyStarted ) continue; QStringList restartCommand = config.readEntry( QLatin1String("restartCommand")+n, QStringList() ); if ( restartCommand.isEmpty() || (config.readEntry( QStringLiteral("restartStyleHint")+n, 0 ) == SmRestartNever)) { continue; } startApplication( restartCommand, config.readEntry( QStringLiteral("clientMachine")+n, QString() ), config.readEntry( QStringLiteral("userId")+n, QString() )); lastIdStarted = clientId; if ( !lastIdStarted.isEmpty() ) { restoreTimer.setSingleShot( true ); restoreTimer.start( 2000 ); return; // we get called again from the clientRegistered handler } } //all done appsToStart = 0; lastIdStarted.clear(); if (state == Restoring) { emit sessionRestored(); } else { //subsession emit subSessionOpened(); } state = Idle; } void KSMServer::startupDone() { state = Idle; } void KSMServer::defaultLogout() { shutdown(KWorkSpace::ShutdownConfirmYes, KWorkSpace::ShutdownTypeDefault, KWorkSpace::ShutdownModeDefault); } void KSMServer::logoutWithoutConfirmation() { shutdown(KWorkSpace::ShutdownConfirmNo, KWorkSpace::ShutdownTypeNone, KWorkSpace::ShutdownModeDefault); } void KSMServer::haltWithoutConfirmation() { shutdown(KWorkSpace::ShutdownConfirmNo, KWorkSpace::ShutdownTypeHalt, KWorkSpace::ShutdownModeDefault); } void KSMServer::rebootWithoutConfirmation() { shutdown(KWorkSpace::ShutdownConfirmNo, KWorkSpace::ShutdownTypeReboot, KWorkSpace::ShutdownModeDefault); } void KSMServer::openSwitchUserDialog() { //this method exists only for compatibility. Users should ideally call this directly OrgKdeScreensaverInterface iface(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus()); iface.SwitchUser(); } diff --git a/login-sessions/plasmawayland-dev.desktop.cmake b/login-sessions/plasmawayland-dev.desktop.cmake index 10a672e76..cd11d5abe 100644 --- a/login-sessions/plasmawayland-dev.desktop.cmake +++ b/login-sessions/plasmawayland-dev.desktop.cmake @@ -1,82 +1,82 @@ [Desktop Entry] -Exec=dbus-run-session @CMAKE_INSTALL_FULL_LIBEXECDIR@/startplasma-dev.sh -wayland +Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/startplasma-dev.sh -wayland DesktopNames=KDE Name=Plasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[ast]=Plasma (Desendolcu, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[ca]=Plasma (Desenvolupament, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[da]=Plasma (udvikling, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[de]=Plasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[en_GB]=Plasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[es]=Plasma (Desarrollo, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[et]=Plasma (arendus, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[eu]=Plasma (Garapena, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[fi]=Plasma (kehitys, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[fr]=Plasma (Développement, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[gl]=Plasma (desenvolvemento, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[hu]=Plasma (Fejlesztői verzió, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[id]=Plasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[it]=Plasma (Sviluppo, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[ko]=Plasma(개발, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[lt]=Plasma (Plėtojimas, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[nl]=Plasma (Ontwikkeling, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[nn]=Plasma (utvikling, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[pa]=ਪਲਾਜ਼ਮਾ (ਡਿਵੈਲਪਮੈਂਟ, ਵੇਅਲੈਂਡ ${CMAKE_INSTALL_FULL_BINDIR}) Name[pl]=Plazma (Rozwój , Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[pt]=Plasma (Desenvolvimento, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[pt_BR]=Plasma (Desenvolvimento, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[ru]=Plasma (разрабатываемая версия, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[sk]=Plasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[sl]=Plasma (Razvoj, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[sv]=Plasma (utveckling, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[uk]=Пзазма (Розробка, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[x-test]=xxPlasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR})xx Name[zh_CN]=Plasma (Development, Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Name[zh_TW]=Plasma (開發版本,Wayland ${CMAKE_INSTALL_FULL_BINDIR}) Comment=Plasma by KDE Comment[ar]=بلازما كدي Comment[ast]=Plasma por KDE Comment[bs]=Plazma od strane KDe Comment[ca]=Plasma, creat per la comunitat KDE Comment[ca@valencia]=Plasma, creat per la comunitat KDE Comment[cs]=Plasma z KDE Comment[da]=Plasma fra KDE Comment[de]=Plasma von KDE Comment[el]=Plasma από το KDE Comment[en_GB]=Plasma by KDE Comment[es]=Plasma, por KDE Comment[et]=KDE Plasma Comment[eu]=KDEren Plasma Comment[fi]=Plasma KDE:ltä Comment[fr]=Plasma, par KDE Comment[gl]=Plasma, fornecido por KDE. Comment[he]=פלזמה באמצעות KDE Comment[hu]=Plasma a KDE-től Comment[ia]=Plasma per KDE Comment[id]=Plasma oleh KDE Comment[is]=Plasma frá KDE Comment[it]=Plasma di KDE Comment[ja]=Plasma by KDE Comment[ko]=KDE Plasma Comment[lt]=Plasma pagal KDE Comment[nb]=Plasma av KDE Comment[nds]=Plasma vun KDE Comment[nl]=Plasma door KDE Comment[nn]=Plasma frå KDE Comment[pa]=KDE ਵਲੋਂ ਪਲਾਜ਼ਮਾ Comment[pl]=Plazma dzięki KDE Comment[pt]=Plasma do KDE Comment[pt_BR]=Plasma do KDE Comment[ru]=KDE Plasma Comment[sk]=Plasma od KDE Comment[sl]=KDE Plasma Comment[sr]=Плазма од КДЕ‑а Comment[sr@ijekavian]=Плазма од КДЕ‑а Comment[sr@ijekavianlatin]=Plasma od KDE‑a Comment[sr@latin]=Plasma od KDE‑a Comment[sv]=Plasma av KDE Comment[tr]=KDE Plasma Comment[uk]=Плазма KDE Comment[x-test]=xxPlasma by KDExx Comment[zh_CN]=KDE Plasma Comment[zh_TW]=Plasma by KDE X-KDE-PluginInfo-Version=${PROJECT_VERSION} diff --git a/login-sessions/plasmawayland.desktop.cmake b/login-sessions/plasmawayland.desktop.cmake index d717ed508..9ef7d5237 100644 --- a/login-sessions/plasmawayland.desktop.cmake +++ b/login-sessions/plasmawayland.desktop.cmake @@ -1,86 +1,86 @@ [Desktop Entry] -Exec=dbus-run-session ${CMAKE_INSTALL_FULL_BINDIR}/startplasma-wayland +Exec=${CMAKE_INSTALL_FULL_BINDIR}/startplasma-wayland TryExec=${CMAKE_INSTALL_FULL_BINDIR}/startplasma-wayland DesktopNames=KDE Name=Plasma (Wayland) Name[ast]=Plasma (Wayland) Name[ca]=Plasma (Wayland) Name[cs]=Plasma (Wayland) Name[da]=Plasma (Wayland) Name[de]=Plasma (Wayland) Name[en_GB]=Plasma (Wayland) Name[es]=Plasma (Wayland) Name[et]=Plasma (Wayland) Name[eu]=Plasma (Wayland) Name[fi]=Plasma (Wayland) Name[fr]=Plasma (Wayland) Name[gl]=Plasma (Wayland) Name[hu]=Plasma (Wayland) Name[ia]=Plasma (Wayland) Name[id]=Plasma (Wayland) Name[it]=Plasma (Wayland) Name[ko]=Plasma(Wayland) Name[lt]=Plasma (Wayland) Name[lv]=Plasma (Wayland) Name[nl]=Plasma (Wayland) Name[nn]=Plasma (Wayland) Name[pa]=ਪਲਾਜ਼ਮਾ (ਵੇਅਲੈਂਡ) Name[pl]=Plazma (Wayland) Name[pt]=Plasma (Wayland) Name[pt_BR]=Plasma (Wayland) Name[ru]=Plasma (Wayland) Name[sk]=Plasma (Wayland) Name[sl]=Plasma (Wayland) Name[sv]=Plasma (Wayland) Name[uk]=Плазма (Wayland) Name[x-test]=xxPlasma (Wayland)xx Name[zh_CN]=Plasma (Wayland) Name[zh_TW]=Plasma (Wayland) Comment=Plasma by KDE Comment[ar]=بلازما كدي Comment[ast]=Plasma por KDE Comment[bs]=Plazma od strane KDe Comment[ca]=Plasma, creat per la comunitat KDE Comment[ca@valencia]=Plasma, creat per la comunitat KDE Comment[cs]=Plasma z KDE Comment[da]=Plasma fra KDE Comment[de]=Plasma von KDE Comment[el]=Plasma από το KDE Comment[en_GB]=Plasma by KDE Comment[es]=Plasma, por KDE Comment[et]=KDE Plasma Comment[eu]=KDEren Plasma Comment[fi]=Plasma KDE:ltä Comment[fr]=Plasma, par KDE Comment[gl]=Plasma, fornecido por KDE. Comment[he]=פלזמה באמצעות KDE Comment[hu]=Plasma a KDE-től Comment[ia]=Plasma per KDE Comment[id]=Plasma oleh KDE Comment[is]=Plasma frá KDE Comment[it]=Plasma di KDE Comment[ja]=Plasma by KDE Comment[ko]=KDE Plasma Comment[lt]=Plasma pagal KDE Comment[nb]=Plasma av KDE Comment[nds]=Plasma vun KDE Comment[nl]=Plasma door KDE Comment[nn]=Plasma frå KDE Comment[pa]=KDE ਵਲੋਂ ਪਲਾਜ਼ਮਾ Comment[pl]=Plazma dzięki KDE Comment[pt]=Plasma do KDE Comment[pt_BR]=Plasma do KDE Comment[ru]=KDE Plasma Comment[sk]=Plasma od KDE Comment[sl]=KDE Plasma Comment[sr]=Плазма од КДЕ‑а Comment[sr@ijekavian]=Плазма од КДЕ‑а Comment[sr@ijekavianlatin]=Plasma od KDE‑a Comment[sr@latin]=Plasma od KDE‑a Comment[sv]=Plasma av KDE Comment[tr]=KDE Plasma Comment[uk]=Плазма KDE Comment[x-test]=xxPlasma by KDExx Comment[zh_CN]=KDE Plasma Comment[zh_TW]=Plasma by KDE X-KDE-PluginInfo-Version=${PROJECT_VERSION} diff --git a/login-sessions/startplasma-dev.sh.cmake b/login-sessions/startplasma-dev.sh.cmake index f8139bc29..27a4d4dc1 100755 --- a/login-sessions/startplasma-dev.sh.cmake +++ b/login-sessions/startplasma-dev.sh.cmake @@ -1,5 +1,12 @@ #!/bin/bash source @CMAKE_INSTALL_FULL_LIBEXECDIR@/plasma-dev-prefix.sh +# This is a bit of a hack done because systemd starts in pam, and we only set our dev paths after all that is complete +# This copies everything into a transient runtime directory that systemd reads and reloads the units + +mkdir -p "$XDG_RUNTIME_DIR/systemd/user.control" +command cp -r @KDE_INSTALL_FULL_SYSTEMDUSERUNITDIR@/* $XDG_RUNTIME_DIR/systemd/user.control +systemctl --user daemon-reload + startplasma$@ diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt index 7efa9f20d..942e92d46 100644 --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -1,102 +1,104 @@ configure_file(config-ktexteditor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ktexteditor.h ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-plasma.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-plasma.h) add_definitions(-DPLASMA_DEPRECATED=) set(scripting_SRC scripting/appinterface.cpp scripting/applet.cpp scripting/containment.cpp scripting/configgroup.cpp scripting/panel.cpp scripting/scriptengine.cpp scripting/scriptengine_v1.cpp scripting/widget.cpp ) set(plasmashell_dbusXML dbus/org.kde.PlasmaShell.xml) qt5_add_dbus_adaptor(scripting_SRC ${plasmashell_dbusXML} shellcorona.h ShellCorona plasmashelladaptor) ecm_qt_declare_logging_category(plasmashell HEADER debug.h IDENTIFIER PLASMASHELL CATEGORY_NAME kde.plasmashell DEFAULT_SEVERITY Info) set (plasma_shell_SRCS alternativeshelper.cpp main.cpp containmentconfigview.cpp currentcontainmentactionsmodel.cpp desktopview.cpp panelview.cpp panelconfigview.cpp panelshadows.cpp shellcorona.cpp standaloneappcorona osd.cpp coronatesthelper.cpp strutmanager.cpp debug.cpp screenpool.cpp softwarerendernotifier.cpp ${scripting_SRC} ) set(krunner_xml ${plasma-workspace_SOURCE_DIR}/krunner/dbus/org.kde.krunner.App.xml) qt5_add_dbus_interface(plasma_shell_SRCS ${krunner_xml} krunner_interface) add_executable(plasmashell ${plasma_shell_SRCS} ) target_link_libraries(plasmashell Qt5::Quick Qt5::DBus KF5::KIOCore KF5::WindowSystem KF5::Crash KF5::Plasma KF5::PlasmaQuick KF5::Solid KF5::Declarative KF5::I18n KF5::Activities KF5::GlobalAccel KF5::CoreAddons KF5::DBusAddons KF5::QuickAddons KF5::XmlGui KF5::Package KF5::WaylandClient KF5::Notifications PW::KWorkspace ) if (TARGET KUserFeedbackCore) target_link_libraries(plasmashell KUserFeedbackCore) target_compile_definitions(plasmashell PRIVATE -DWITH_KUSERFEEDBACKCORE) endif() target_include_directories(plasmashell PRIVATE "${CMAKE_BINARY_DIR}") target_compile_definitions(plasmashell PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") if(HAVE_X11) target_link_libraries(plasmashell ${X11_LIBRARIES} ${XCB_LIBRARIES} ) target_link_libraries(plasmashell Qt5::X11Extras) endif() configure_file(org.kde.plasmashell.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.kde.plasmashell.desktop @ONLY) install(TARGETS plasmashell ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.plasmashell.desktop DESTINATION ${KDE_INSTALL_APPDIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.plasmashell.desktop DESTINATION ${KDE_INSTALL_AUTOSTARTDIR}) install( FILES dbus/org.kde.PlasmaShell.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} ) +ecm_install_configured_files(TEMPLATES plasma-plasmashell.service.in @ONLY DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) + install(FILES scripting/plasma-layouttemplate.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) add_subdirectory(packageplugins) if(BUILD_TESTING) add_subdirectory(autotests) endif() diff --git a/shell/org.kde.plasmashell.desktop.cmake b/shell/org.kde.plasmashell.desktop.cmake index fd77027d7..b7d681e7a 100644 --- a/shell/org.kde.plasmashell.desktop.cmake +++ b/shell/org.kde.plasmashell.desktop.cmake @@ -1,61 +1,63 @@ [Desktop Entry] Exec=@CMAKE_INSTALL_PREFIX@/bin/plasmashell X-DBUS-StartupType=Unique Name=Plasma Desktop Workspace Name[ar]=مساحة عمل سطح مكتب بلازما Name[bs]=Radni prostor plazma radne površi Name[ca]=Espai de treball de l'escriptori Plasma Name[ca@valencia]=Espai de treball de l'escriptori Plasma Name[cs]=Pracovní plocha Plasma Name[da]=Plasma Desktop Workspace Name[de]=Plasma-Arbeitsflächenbereich Name[el]=Χώρος επιφάνειας εργασίας Plasma Name[en_GB]=Plasma Desktop Workspace Name[es]=Espacio de trabajo del escritorio Plasma Name[et]=Plasma töölaua töötsoon Name[eu]=Plasma mahaigainaren lanerako guneak Name[fi]=Plasma-työpöytä Name[fr]=Espace de travail Plasma Name[ga]=Spás Oibre Deisce Plasma Name[gl]=Espazo de traballo do escritorio Plasma Name[he]=תחנת עבודה של שולחן העבודה Plasma Name[hr]=Plasma radno okruženje Name[hu]=Plazma asztali munkaterület Name[ia]=Spatio de labor de scriptorio de Plasma Name[id]=Ruangkerja Desktop Plasma Name[is]=Vinnurýmd Plasma skjáborðs Name[it]=Spazio di lavoro del desktop di Plasma Name[ja]=Plasma デスクトップワークスペース Name[ko]=Plasma 데스크톱 작업 공간 Name[lt]=Plasma darbalaukio darbo sritis Name[nb]=Arbeidsrom for Plasma skrivebord Name[nds]=Plasma-Schriefdischarbeitrebeet Name[nl]=Plasma Bureaublad Werkplek Name[nn]=Arbeidsområde for Plasma-skrivebord Name[pa]=ਪਲਾਜ਼ਮਾ ਡੈਸਕਟਾਪ ਵਰਕਸਪੇਸ Name[pl]=Przestrzeń Pracy Pulpitu Plazmy Name[pt]=Área de Trabalho do Plasma Name[pt_BR]=Espaço de Trabalho Plasma Name[ru]=Рабочая среда Plasma Name[sk]=Pracovná plocha Plasma Name[sl]=Delovni prostor Plasma Desktop Name[sr]=Плазма, радни простор површи Name[sr@ijekavian]=Плазма, радни простор површи Name[sr@ijekavianlatin]=Plasma, radni prostor površi Name[sr@latin]=Plasma, radni prostor površi Name[sv]=Plasma arbetsområde för skrivbordet Name[tg]=Фазои мизи кории Плазма Name[tr]=Plasma Masaüstü Çalışma Alanı Name[uk]=Робочий простір Плазми для комп’ютерів Name[x-test]=xxPlasma Desktop Workspacexx Name[zh_CN]=Plasma 桌面工作空间 Name[zh_TW]=Plasma 桌面工作空間 Type=Application X-KDE-StartupNotify=false +X-KDE-HiddenUnderSystemd=true X-DBUS-ServiceName=org.kde.plasmashell OnlyShowIn=KDE; X-KDE-autostart-phase=0 Icon=plasma NoDisplay=true +X-systemd-hidden=true X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_kwin_keystate diff --git a/shell/plasma-plasmashell.service.in b/shell/plasma-plasmashell.service.in new file mode 100644 index 000000000..8c8cdca4d --- /dev/null +++ b/shell/plasma-plasmashell.service.in @@ -0,0 +1,15 @@ +[Unit] +Description=KDE Plasma Workspace +Wants=plasma-ksmserver.service plasma-kcminit.service + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/plasmashell --no-respawn +Restart=on-failure +KillMode=process +Type=dbus +BusName=org.kde.plasmashell +Slice=session.slice +TimeoutSec=5sec + +[Install] +WantedBy=plasma-core.target diff --git a/startkde/CMakeLists.txt b/startkde/CMakeLists.txt index 57f46c319..3d10c0f3b 100644 --- a/startkde/CMakeLists.txt +++ b/startkde/CMakeLists.txt @@ -1,44 +1,50 @@ add_subdirectory(kcminit) add_subdirectory(ksyncdbusenv) add_subdirectory(waitforname) add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII) add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) qt5_add_dbus_interface( startplasma_SRCS ${CMAKE_SOURCE_DIR}/ksplash/ksplashqml/org.kde.KSplash.xml ksplashinterface ) add_executable(startplasma-x11 startplasma.cpp startplasma-x11.cpp kcheckrunning/kcheckrunning.cpp ${startplasma_SRCS}) add_executable(startplasma-wayland startplasma.cpp startplasma-wayland.cpp ${startplasma_SRCS}) add_executable(startplasma-waylandsession startplasma.cpp startplasma-waylandsession.cpp ${startplasma_SRCS}) add_executable(kde-systemd-start-condition kde-systemd-start-condition.cpp) target_include_directories(startplasma-x11 PRIVATE ${X11_X11_INCLUDE_PATH}) target_link_libraries(startplasma-x11 PRIVATE Qt5::Core Qt5::DBus KF5::ConfigCore ${X11_X11_LIB} # for kcheckrunning ) target_link_libraries(startplasma-wayland PRIVATE Qt5::Core Qt5::DBus KF5::ConfigCore) target_link_libraries(startplasma-waylandsession PRIVATE Qt5::Core Qt5::DBus KF5::ConfigCore) target_link_libraries(kde-systemd-start-condition PUBLIC KF5::ConfigCore KF5::Service) add_subdirectory(plasma-session) add_subdirectory(plasma-shutdown) #FIXME: reconsider, looks fishy if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr") set_property(SOURCE startplasma.cpp APPEND PROPERTY COMPILE_DEFINITIONS XCURSOR_PATH="${KDE_INSTALL_FULL_DATAROOTDIR}/icons:$XCURSOR_PATH:~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons") endif() configure_file(config-startplasma.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-startplasma.h) install(TARGETS startplasma-x11 ${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}) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") install(TARGETS kde-systemd-start-condition DESTINATION ${KDE_INSTALL_BINDIR}) -endif () +endif() + +ecm_install_configured_files(TEMPLATES plasma-ksplash-ready.service.in @ONLY + DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) + +install(FILES plasma-core@.target DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) +install(FILES plasma-workspace@.target DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) diff --git a/startkde/kcminit/CMakeLists.txt b/startkde/kcminit/CMakeLists.txt index 366b0e426..29eefec4f 100644 --- a/startkde/kcminit/CMakeLists.txt +++ b/startkde/kcminit/CMakeLists.txt @@ -1,42 +1,45 @@ find_package(XCB OPTIONAL_COMPONENTS XCB) set_package_properties(XCB PROPERTIES DESCRIPTION "Xcb libraries" URL "https://www.x.org" TYPE OPTIONAL PURPOSE "Required for enabling special X11 multihead mode") configure_file(config-xcb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-xcb.h) ########### next target ############### set(kcminit_KDEINIT_SRCS main.cpp) set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) qt5_add_dbus_interface(kcminit_KDEINIT_SRCS ${klauncher_xml} klauncher_iface) kf5_add_kdeinit_executable( kcminit ${kcminit_KDEINIT_SRCS}) target_link_libraries(kdeinit_kcminit Qt5::Core Qt5::Gui Qt5::DBus KF5::CoreAddons KF5::Service KF5::I18n PW::KWorkspace) if (XCB_XCB_FOUND) target_link_libraries(kdeinit_kcminit XCB::XCB) endif() install(TARGETS kdeinit_kcminit ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kcminit ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) ########### next target ############### # TODO might be simpler to make _startup to be a symlink to set(kcminit_startup_KDEINIT_SRCS main.cpp) qt5_add_dbus_interface(kcminit_startup_KDEINIT_SRCS ${klauncher_xml} klauncher_iface) kf5_add_kdeinit_executable( kcminit_startup ${kcminit_startup_KDEINIT_SRCS}) +ecm_install_configured_files(TEMPLATES plasma-kcminit-phase1.service.in plasma-kcminit.service.in + DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) + target_link_libraries(kdeinit_kcminit_startup Qt5::Core Qt5::Gui Qt5::DBus KF5::CoreAddons KF5::Service KF5::I18n PW::KWorkspace) if (XCB_XCB_FOUND) target_link_libraries(kdeinit_kcminit_startup XCB::XCB) endif() install(TARGETS kdeinit_kcminit_startup ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kcminit_startup ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/startkde/kcminit/plasma-kcminit-phase1.service.in b/startkde/kcminit/plasma-kcminit-phase1.service.in new file mode 100644 index 000000000..79f1f9463 --- /dev/null +++ b/startkde/kcminit/plasma-kcminit-phase1.service.in @@ -0,0 +1,9 @@ +[Unit] +Description=KDE Configuration Module Initialization (Phase 1) +Requires=kcminit.service +After=plasma-kcminit.service plasma-kded.service + +[Service] +Type=oneshot +ExecStart=@QtBinariesDir@/qdbus org.kde.kcminit /kcminit org.kde.KCMInit.runPhase1 +Slice=session.slice diff --git a/startkde/kcminit/plasma-kcminit.service.in b/startkde/kcminit/plasma-kcminit.service.in new file mode 100644 index 000000000..6376ee763 --- /dev/null +++ b/startkde/kcminit/plasma-kcminit.service.in @@ -0,0 +1,11 @@ +[Unit] +Description=KDE Config Module Initialization + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/kcminit_startup +Restart=no +Type=forking +Slice=session.slice + +[Install] +Alias=plasma-workspace.service diff --git a/startkde/plasma-core@.target b/startkde/plasma-core@.target new file mode 100644 index 000000000..64b39aaa1 --- /dev/null +++ b/startkde/plasma-core@.target @@ -0,0 +1,5 @@ +[Unit] +Description=KDE Plasma Workspace Core +Wants=plasma-plasmashell.service plasma-kwin_%i.service plasma-kcminit.service plasma-kded.service plasma-kcminit-phase1.service +Requires=plasma-ksmserver.service +BindsTo=plasma-ksmserver.service diff --git a/startkde/plasma-ksplash-ready.service.in b/startkde/plasma-ksplash-ready.service.in new file mode 100644 index 000000000..943330aa8 --- /dev/null +++ b/startkde/plasma-ksplash-ready.service.in @@ -0,0 +1,9 @@ +[Unit] +Description=KSplash "ready" Stage +Wants=plasma-core.target +After=plasma-core.target + +[Service] +Type=oneshot +ExecStart=-@QtBinariesDir@/qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage ready +Slice=session.slice diff --git a/startkde/plasma-workspace@.target b/startkde/plasma-workspace@.target new file mode 100644 index 000000000..a8f9cfbaa --- /dev/null +++ b/startkde/plasma-workspace@.target @@ -0,0 +1,5 @@ +[Unit] +Description=KDE Plasma Workspace +Requires=plasma-core@%i.target plasma-ksplash-ready.service +Wants=xdg-desktop.target +After=plasma-core.target diff --git a/startkde/startplasma.cpp b/startkde/startplasma.cpp index 7d8631f5a..6982f08f2 100644 --- a/startkde/startplasma.cpp +++ b/startkde/startplasma.cpp @@ -1,438 +1,459 @@ /* This file is part of the KDE project Copyright (C) 2019 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include "startplasma.h" +#include "../config-workspace.h" + + QTextStream out(stderr); void messageBox(const QString &text) { out << text; runSync(QStringLiteral("xmessage"), {QStringLiteral("-geometry"), QStringLiteral("500x100"), text}); } QStringList allServices(const QLatin1String& prefix) { QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface(); const QStringList services = bus->registeredServiceNames(); QMap servicesWithAliases; for (const QString &serviceName : services) { QDBusReply reply = bus->serviceOwner(serviceName); QString owner = reply; if (owner.isEmpty()) owner = serviceName; servicesWithAliases[owner].append(serviceName); } QStringList names; for (auto it = servicesWithAliases.constBegin(); it != servicesWithAliases.constEnd(); ++it) { if (it.value().startsWith(prefix)) names << it.value(); } names.removeDuplicates(); names.sort(); return names; } int runSync(const QString& program, const QStringList &args, const QStringList &env) { QProcess p; if (!env.isEmpty()) p.setEnvironment(QProcess::systemEnvironment() << env); p.setProcessChannelMode(QProcess::ForwardedChannels); p.start(program, args); // qDebug() << "started..." << program << args; p.waitForFinished(-1); if (p.exitCode()) { qWarning() << program << args << "exited with code" << p.exitCode(); } return p.exitCode(); } void sourceFiles(const QStringList &files) { QStringList filteredFiles; std::copy_if(files.begin(), files.end(), std::back_inserter(filteredFiles), [](const QString& i){ return QFileInfo(i).isReadable(); } ); if (filteredFiles.isEmpty()) return; filteredFiles.prepend(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR "/plasma-sourceenv.sh")); QProcess p; p.start(QStringLiteral("/bin/sh"), filteredFiles); p.waitForFinished(-1); const auto fullEnv = p.readAllStandardOutput(); auto envs = fullEnv.split('\0'); for (auto &env: envs) { if (env.startsWith("_=") || env.startsWith("SHLVL")) continue; const int idx = env.indexOf('='); if (Q_UNLIKELY(idx <= 0)) continue; if (qgetenv(env.left(idx)) != env.mid(idx+1)) { // qDebug() << "setting..." << env.left(idx) << env.mid(idx+1) << "was" << qgetenv(env.left(idx)); qputenv(env.left(idx), env.mid(idx+1)); } } } void createConfigDirectory() { const QString configDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); if (!QDir().mkpath(configDir)) out << "Could not create config directory XDG_CONFIG_HOME: " << configDir << '\n'; } void runStartupConfig() { //export LC_* variables set by kcmshell5 formats into environment //so it can be picked up by QLocale and friends. KConfig config(QStringLiteral("plasma-localerc")); KConfigGroup formatsConfig = KConfigGroup(&config, "Formats"); const auto lcValues = { "LANG", "LC_NUMERIC", "LC_TIME", "LC_MONETARY", "LC_MEASUREMENT", "LC_COLLATE", "LC_CTYPE" }; for (auto lc : lcValues) { const QString value = formatsConfig.readEntry(lc, QString()); if (!value.isEmpty()) { qputenv(lc, value.toUtf8()); } } KConfigGroup languageConfig = KConfigGroup(&config, "Translations"); const QString value = languageConfig.readEntry("LANGUAGE", QString()); if (!value.isEmpty()) { qputenv("LANGUAGE", value.toUtf8()); } if (!formatsConfig.hasKey("LANG") && !qEnvironmentVariableIsEmpty("LANG")) { formatsConfig.writeEntry("LANG", qgetenv("LANG")); formatsConfig.sync(); } } void setupCursor(bool wayland) { const KConfig cfg(QStringLiteral("kcminputrc")); const KConfigGroup inputCfg = cfg.group("Mouse"); const auto kcminputrc_mouse_cursorsize = inputCfg.readEntry("cursorSize", 24); const auto kcminputrc_mouse_cursortheme = inputCfg.readEntry("cursorTheme", QStringLiteral("breeze_cursors")); if (!kcminputrc_mouse_cursortheme.isEmpty()) { #ifdef XCURSOR_PATH QByteArray path(XCURSOR_PATH); path.replace("$XCURSOR_PATH", qgetenv("XCURSOR_PATH")); qputenv("XCURSOR_PATH", path); #endif } //TODO: consider linking directly const int applyMouseStatus = wayland ? 0 : runSync(QStringLiteral("kapplymousetheme"), { kcminputrc_mouse_cursortheme, QString::number(kcminputrc_mouse_cursorsize) }); if (applyMouseStatus == 10) { qputenv("XCURSOR_THEME", "breeze_cursors"); } else if (!kcminputrc_mouse_cursortheme.isEmpty()) { qputenv("XCURSOR_THEME", kcminputrc_mouse_cursortheme.toUtf8()); } qputenv("XCURSOR_SIZE", QByteArray::number(kcminputrc_mouse_cursorsize)); } // Source scripts found in /plasma-workspace/env/*.sh // (where correspond to the system and user's configuration // directory. // // Scripts are sourced in reverse order of priority of their directory, as defined // by `QStandardPaths::standardLocations`. This ensures that high-priority scripts // (such as those in the user's home directory) are sourced last and take precedence // over lower-priority scripts (such as system defaults). Scripts in the same // directory are sourced in lexical order of their filename. // // This is where you can define environment variables that will be available to // all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent` // or eval `gpg-agent --daemon`. // Note: if you do that, you should also put "ssh-agent -k" as a shutdown script // // (see end of this file). // For anything else (that doesn't set env vars, or that needs a window manager), // better use the Autostart folder. void runEnvironmentScripts() { QStringList scripts; auto locations = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); //`standardLocations()` returns locations sorted by "order of priority". We iterate in reverse // order so that high-priority scripts are sourced last and their modifications take precedence. for (auto loc = locations.crbegin(); loc != locations.crend(); loc++) { QDir dir(*loc); if (! dir.cd(QStringLiteral("./plasma-workspace/env"))) { // Skip location if plasma-workspace/env subdirectory does not exist continue; } const auto dirScripts = dir.entryInfoList({QStringLiteral("*.sh")}, QDir::Files, QDir::Name); for (const auto script : dirScripts) { scripts << script.absoluteFilePath(); } } sourceFiles(scripts); } // Mark that full KDE session is running (e.g. Konqueror preloading works only // with full KDE running). The KDE_FULL_SESSION property can be detected by // any X client connected to the same X session, even if not launched // directly from the KDE session but e.g. using "ssh -X", kdesu. $KDE_FULL_SESSION // however guarantees that the application is launched in the same environment // like the KDE session and that e.g. KDE utilities/libraries are available. // KDE_FULL_SESSION property is also only available since KDE 3.5.5. // The matching tests are: // For $KDE_FULL_SESSION: // if test -n "$KDE_FULL_SESSION"; then ... whatever // For KDE_FULL_SESSION property (on X11): // xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null // if test $? -eq 0; then ... whatever // // Additionally there is $KDE_SESSION_UID with the uid // of the user running the KDE session. It should be rarely needed (e.g. // after sudo to prevent desktop-wide functionality in the new user's kded). // // Since KDE4 there is also KDE_SESSION_VERSION, containing the major version number. // void setupPlasmaEnvironment() { //Manually disable auto scaling because we are scaling above //otherwise apps that manually opt in for high DPI get auto scaled by the developer AND manually scaled by us qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0"); qputenv("KDE_FULL_SESSION", "true"); qputenv("KDE_SESSION_VERSION", "5"); qputenv("KDE_SESSION_UID", QByteArray::number(getuid())); qputenv("XDG_CURRENT_DESKTOP", "KDE"); qputenv("KDE_APPLICATIONS_AS_SCOPE", "1"); } void setupX11() { // Set a left cursor instead of the standard X11 "X" cursor, since I've heard // from some users that they're confused and don't know what to do. This is // especially necessary on slow machines, where starting KDE takes one or two // minutes until anything appears on the screen. // // If the user has overwritten fonts, the cursor font may be different now // so don't move this up. runSync(QStringLiteral("xsetroot"), {QStringLiteral("-cursor_name"), QStringLiteral("left_ptr")}); runSync(QStringLiteral("xprop"), {QStringLiteral("-root"), QStringLiteral("-f"), QStringLiteral("KDE_FULL_SESSION"), QStringLiteral("8t"), QStringLiteral("-set"), QStringLiteral("KDE_FULL_SESSION"), QStringLiteral("true")}); runSync(QStringLiteral("xprop"), {QStringLiteral("-root"), QStringLiteral("-f"), QStringLiteral("KDE_SESSION_VERSION"), QStringLiteral("32c"), QStringLiteral("-set"), QStringLiteral("KDE_SESSION_VERSION"), QStringLiteral("5")}); } void cleanupX11() { runSync(QStringLiteral("xprop"), { QStringLiteral("-root"), QStringLiteral("-remove"), QStringLiteral("KDE_FULL_SESSION") }); runSync(QStringLiteral("xprop"), { QStringLiteral("-root"), QStringLiteral("-remove"), QStringLiteral("KDE_SESSION_VERSION") }); } // TODO: Check if Necessary void cleanupPlasmaEnvironment() { qunsetenv("KDE_FULL_SESSION"); qunsetenv("KDE_SESSION_VERSION"); qunsetenv("KDE_SESSION_UID"); } // kwin_wayland can possibly also start dbus-activated services which need env variables. // In that case, the update in startplasma might be too late. bool syncDBusEnvironment() { int exitCode; // At this point all environment variables are set, let's send it to the DBus session server to update the activation environment if (!QStandardPaths::findExecutable(QStringLiteral("dbus-update-activation-environment")).isEmpty()) { exitCode = runSync(QStringLiteral("dbus-update-activation-environment"), { QStringLiteral("--systemd"), QStringLiteral("--all") }); } else { exitCode = runSync(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR "/ksyncdbusenv"), {}); } return exitCode == 0; } void setupFontDpi() { KConfig cfg(QStringLiteral("kcmfonts")); KConfigGroup fontsCfg(&cfg, "General"); if (!fontsCfg.hasKey("forceFontDPI")) { return; } //TODO port to c++? const QByteArray input = "Xft.dpi: " + QByteArray::number(fontsCfg.readEntry("forceFontDPI", 0)); QProcess p; p.start(QStringLiteral("xrdb"), { QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp") }); p.setProcessChannelMode(QProcess::ForwardedChannels); p.write(input); p.closeWriteChannel(); p.waitForFinished(-1); } static bool desktopLockedAtStart = false; QProcess* setupKSplash() { const auto dlstr = qgetenv("DESKTOP_LOCKED"); desktopLockedAtStart = dlstr == "true" || dlstr == "1"; qunsetenv("DESKTOP_LOCKED"); // Don't want it in the environment QProcess* p = nullptr; if (!desktopLockedAtStart) { const KConfig cfg(QStringLiteral("ksplashrc")); // the splashscreen and progress indicator KConfigGroup ksplashCfg = cfg.group("KSplash"); if (ksplashCfg.readEntry("Engine", QStringLiteral("KSplashQML")) == QLatin1String("KSplashQML")) { p = new QProcess; p->start(QStringLiteral("ksplashqml"), { ksplashCfg.readEntry("Theme", QStringLiteral("Breeze")) }); } } return p; } void setupGSLib() // Get Ghostscript to look into user's KDE fonts dir for additional Fontmap { const QByteArray usr_fdir = QFile::encodeName(QDir::home().absoluteFilePath(QStringLiteral(".fonts"))); if (qEnvironmentVariableIsSet("GS_LIB")) { qputenv("GS_LIB", usr_fdir + ':' + qgetenv("GS_LIB")); } else { qputenv("GS_LIB", usr_fdir); } } bool startPlasmaSession(bool wayland) { OrgKdeKSplashInterface iface(QStringLiteral("org.kde.KSplash"), QStringLiteral("/KSplash"), QDBusConnection::sessionBus()); iface.setStage(QStringLiteral("kinit")); // finally, give the session control to the session manager // see kdebase/ksmserver for the description of the rest of the startup sequence // if the KDEWM environment variable has been set, then it will be used as KDE's // window manager instead of kwin. // if KDEWM is not set, ksmserver will ensure kwin is started. // kwrapper5 is used to reduce startup time and memory usage // kwrapper5 does not return useful error codes such as the exit code of ksmserver. // We only check for 255 which means that the ksmserver process could not be // started, any problems thereafter, e.g. ksmserver failing to initialize, // will remain undetected. // If the session should be locked from the start (locked autologin), // lock now and do the rest of the KDE startup underneath the locker. - - QStringList plasmaSessionOptions; - if (wayland) { - plasmaSessionOptions << QStringLiteral("--no-lockscreen"); - } else { - if (desktopLockedAtStart) { - plasmaSessionOptions << QStringLiteral("--lockscreen"); - } - } - bool rc = true; QEventLoop e; - QProcess startPlasmaSession; - startPlasmaSession.setProcessChannelMode(QProcess::ForwardedChannels); - QDBusServiceWatcher serviceWatcher; serviceWatcher.setConnection(QDBusConnection::sessionBus()); // We want to exit when both ksmserver and plasma-session-shutdown have finished // This also closes if ksmserver crashes unexpectedly, as in those cases plasma-shutdown is not running serviceWatcher.addWatchedService(QStringLiteral("org.kde.ksmserver")); serviceWatcher.addWatchedService(QStringLiteral("org.kde.shutdown")); serviceWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); - QObject::connect(&startPlasmaSession, QOverload::of(&QProcess::finished), [&rc, &e](int exitCode, QProcess::ExitStatus) { - if (exitCode == 255) { - // Startup error - messageBox(QStringLiteral("startkde: Could not start ksmserver. Check your installation.\n")); - rc = false; - e.quit(); - } - }); - QObject::connect(&serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, [&]() { const QStringList watchedServices = serviceWatcher.watchedServices(); bool plasmaSessionRunning = std::any_of(watchedServices.constBegin(), watchedServices.constEnd(), [](const QString &service) { return QDBusConnection::sessionBus().interface()->isServiceRegistered(service); }); if (!plasmaSessionRunning) { e.quit(); } }); +#ifndef PLASMA_SYSTEMD_BOOT + QProcess startPlasmaSession; + + QStringList plasmaSessionOptions; + if (wayland) { + plasmaSessionOptions << QStringLiteral("--no-lockscreen"); + } else { + if (desktopLockedAtStart) { + plasmaSessionOptions << QStringLiteral("--lockscreen"); + } + } + + startPlasmaSession.setProcessChannelMode(QProcess::ForwardedChannels); + QObject::connect(&startPlasmaSession, QOverload::of(&QProcess::finished), [&rc, &e](int exitCode, QProcess::ExitStatus) { + if (exitCode == 255) { + // Startup error + messageBox(QStringLiteral("startkde: Could not start ksmserver. Check your installation.\n")); + rc = false; + e.quit(); + } + }); + startPlasmaSession.start(QStringLiteral(CMAKE_INSTALL_FULL_BINDIR "/plasma_session"), plasmaSessionOptions); - e.exec(); + rc = startPlasmaSession.waitForStarted(); +#else + + const QString platform = wayland ? QStringLiteral("wayland") : QStringLiteral("x11"); + + auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"), + QStringLiteral("/org/freedesktop/systemd1"), + QStringLiteral("org.freedesktop.systemd1.Manager"), + QStringLiteral("StartUnit")); + msg << QStringLiteral("plasma-workspace@%1.target").arg(platform) << QStringLiteral("fail"); + auto reply = QDBusConnection::sessionBus().call(msg); + if (reply.type() == QDBusMessage::ErrorMessage) { + rc = false; + } +#endif + + if (rc) { + e.exec(); + } return rc; } void waitForKonqi() { const KConfig cfg(QStringLiteral("startkderc")); const KConfigGroup grp = cfg.group("WaitForDrKonqi"); bool wait_drkonqi = grp.readEntry("Enabled", true); if (wait_drkonqi) { // wait for remaining drkonqi instances with timeout (in seconds) const int wait_drkonqi_timeout = grp.readEntry("Timeout", 900) * 1000; QElapsedTimer wait_drkonqi_counter; wait_drkonqi_counter.start(); QStringList services = allServices(QLatin1String("org.kde.drkonqi-")); while (!services.isEmpty()) { sleep(5); services = allServices(QLatin1String("org.kde.drkonqi-")); if (wait_drkonqi_counter.elapsed() >= wait_drkonqi_timeout) { // ask remaining drkonqis to die in a graceful way for (const auto &service: services) { QDBusInterface iface(service, QStringLiteral("/MainApplication")); iface.call(QStringLiteral("quit")); } break; } } } } diff --git a/xembed-sni-proxy/CMakeLists.txt b/xembed-sni-proxy/CMakeLists.txt index c2f67ac66..264e835db 100644 --- a/xembed-sni-proxy/CMakeLists.txt +++ b/xembed-sni-proxy/CMakeLists.txt @@ -1,66 +1,67 @@ add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_URL_CAST_FROM_STRING -DQT_NO_CAST_FROM_BYTEARRAY) find_package(XCB REQUIRED COMPONENTS XCB XFIXES DAMAGE COMPOSITE RANDR SHM UTIL IMAGE ) set(XCB_LIBS XCB::XCB XCB::XFIXES XCB::DAMAGE XCB::COMPOSITE XCB::RANDR XCB::SHM XCB::UTIL XCB::IMAGE ) set(XEMBED_SNI_PROXY_SOURCES main.cpp fdoselectionmanager.cpp snidbus.cpp sniproxy.cpp xtestsender.cpp ) qt5_add_dbus_adaptor(XEMBED_SNI_PROXY_SOURCES org.kde.StatusNotifierItem.xml sniproxy.h SNIProxy) set(statusnotifierwatcher_xml org.kde.StatusNotifierWatcher.xml) qt5_add_dbus_interface(XEMBED_SNI_PROXY_SOURCES ${statusnotifierwatcher_xml} statusnotifierwatcher_interface) ecm_qt_declare_logging_category(XEMBED_SNI_PROXY_SOURCES HEADER debug.h IDENTIFIER SNIPROXY CATEGORY_NAME kde.xembedsniproxy DEFAULT_SEVERITY Info) add_executable(xembedsniproxy ${XEMBED_SNI_PROXY_SOURCES}) set_package_properties(XCB PROPERTIES TYPE REQUIRED) target_link_libraries(xembedsniproxy Qt5::Core Qt5::X11Extras Qt5::DBus KF5::WindowSystem ${XCB_LIBS} ${X11_XTest_LIB} ) install(TARGETS xembedsniproxy ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES xembedsniproxy.desktop DESTINATION ${KDE_INSTALL_AUTOSTARTDIR}) +ecm_install_configured_files(TEMPLATES plasma-xembedsniproxy.service.in @ONLY DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR}) diff --git a/xembed-sni-proxy/plasma-xembedsniproxy.service.in b/xembed-sni-proxy/plasma-xembedsniproxy.service.in new file mode 100644 index 000000000..2e8ca95d7 --- /dev/null +++ b/xembed-sni-proxy/plasma-xembedsniproxy.service.in @@ -0,0 +1,13 @@ +[Unit] +Description=Handle legacy xembed system tray icons + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/xembedsniproxy +Restart=on-failure +KillMode=process +Type=simple +Slice=background.slice +TimeoutSec=5sec + +[Install] +WantedBy=plasma-workspace.target diff --git a/xembed-sni-proxy/xembedsniproxy.desktop b/xembed-sni-proxy/xembedsniproxy.desktop index a6b3715fe..69bdeddc6 100644 --- a/xembed-sni-proxy/xembedsniproxy.desktop +++ b/xembed-sni-proxy/xembedsniproxy.desktop @@ -1,46 +1,47 @@ [Desktop Entry] Exec=xembedsniproxy Name=XembedSniProxy Name[ast]=XembedSniProxy Name[ca]=XembedSniProxy Name[ca@valencia]=XembedSniProxy Name[cs]=XembedSniProxy Name[da]=XembedSniProxy Name[de]=XembedSniProxy Name[el]=XembedSniProxy Name[en_GB]=XembedSniProxy Name[es]=XembedSniProxy Name[et]=XembedSniProxy Name[eu]=XembedSniProxy Name[fi]=XembedSniProxy Name[fr]=XembedSniProxy Name[gl]=XembedSniProxy Name[hu]=XembedSniProxy Name[id]=XembedSniProxy Name[is]=XembedSniProxy Name[it]=XembedSniProxy Name[ko]=XembedSniProxy Name[lt]=XembedSniProxy Name[nl]=XembedSniProxy Name[nn]=XembedSniProxy Name[pa]=XembedSniProxy Name[pl]=XembedSniProxy Name[pt]=XembedSniProxy Name[pt_BR]=XembedSniProxy Name[ru]=XembedSniProxy Name[sk]=XembedSniProxy Name[sl]=XembedSniProxy Name[sr]=Иксембед‑сни‑прокси Name[sr@ijekavian]=Иксембед‑сни‑прокси Name[sr@ijekavianlatin]=XembedSniProxy Name[sr@latin]=XembedSniProxy Name[sv]=XembedSniProxy Name[tr]=XembedSniProxy Name[uk]=XembedSniProxy Name[x-test]=xxXembedSniProxyxx Name[zh_CN]=XembedSniProxy Name[zh_TW]=XembedSniProxy Type=Application X-KDE-StartupNotify=false OnlyShowIn=KDE; X-KDE-autostart-phase=0 +X-systemd-hidden=true