File indexing completed on 2024-05-19 05:39:09

0001 /*
0002     SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "../plasmaautostart/plasmaautostart.h"
0008 #include <QCommandLineOption>
0009 #include <QCommandLineParser>
0010 #include <QCoreApplication>
0011 
0012 int main(int argc, char **argv)
0013 {
0014     QCoreApplication app(argc, argv);
0015 
0016     // If invoked on gnome we should always return success
0017     // this is because a desktop file that has X-KDE-AutostartCondition
0018     // probably has an X-Gnome- equivalent and we only want one to run
0019     // this would match non systemd behaviour
0020     if (!qEnvironmentVariable("XDG_CURRENT_DESKTOP").split(QLatin1Char(':')).contains("kde", Qt::CaseInsensitive)) {
0021         return 0;
0022     }
0023     QCommandLineParser parser;
0024     parser.setApplicationDescription(QStringLiteral("Checks start condition for a KDE systemd service"));
0025     parser.addHelpOption();
0026     QCommandLineOption option{QStringLiteral("condition"),
0027                               QStringLiteral("start condition, in the format 'rcfile:group:entry:default'."),
0028                               QStringLiteral("condition")};
0029     parser.addOption(option);
0030     parser.process(app);
0031 
0032     if (!parser.isSet(option)) {
0033         parser.showHelp(255);
0034     }
0035 
0036     if (PlasmaAutostart::isStartConditionMet(parser.value(option))) {
0037         return 0;
0038     } else {
0039         return 1;
0040     }
0041 }