diff --git a/startkde/CMakeLists.txt b/startkde/CMakeLists.txt index f152bd187..57f46c319 100644 --- a/startkde/CMakeLists.txt +++ b/startkde/CMakeLists.txt @@ -1,39 +1,44 @@ 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 () diff --git a/startkde/kde-systemd-start-condition.cpp b/startkde/kde-systemd-start-condition.cpp new file mode 100644 index 000000000..1b2b73292 --- /dev/null +++ b/startkde/kde-systemd-start-condition.cpp @@ -0,0 +1,44 @@ +/* + Copyright (c) 2020 Henri Chain + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + QCommandLineParser parser; + parser.setApplicationDescription(QStringLiteral("Checks start condition for a KDE systemd service")); + parser.addHelpOption(); + parser.addPositionalArgument(QStringLiteral("condition"), + QStringLiteral("start condition, in the format 'rcfile:group:entry:default'")); + parser.process(app); + + if (!parser.positionalArguments().count()) { + parser.showHelp(0); + } + + if (KAutostart::isStartConditionMet(parser.positionalArguments().at(0))) { + return 0; + } else { + return 255; + } +}