Changeset View
Changeset View
Standalone View
Standalone View
startkde/kde-systemd-start-condition.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (c) 2020 Henri Chain <henri.chain@enioka.com> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or modify | ||||
5 | it under the terms of the GNU General Public License as published by | ||||
6 | the Free Software Foundation; either version 2 of the License, or | ||||
7 | (at your option) any later version. | ||||
8 | | ||||
9 | This program is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | GNU General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program; if not, write to the Free Software | ||||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | | ||||
18 | */ | ||||
19 | | ||||
20 | #include <kautostart.h> | ||||
21 | #include <QCommandLineOption> | ||||
22 | #include <QCommandLineParser> | ||||
23 | #include <QCoreApplication> | ||||
24 | | ||||
25 | int main(int argc, char **argv) | ||||
26 | { | ||||
27 | QCoreApplication app(argc, argv); | ||||
28 | QCommandLineParser parser; | ||||
29 | parser.setApplicationDescription(QStringLiteral("Checks start condition for a KDE systemd service")); | ||||
30 | parser.addHelpOption(); | ||||
31 | parser.addPositionalArgument(QStringLiteral("condition"), | ||||
32 | QStringLiteral("start condition, in the format 'rcfile:group:entry:default'")); | ||||
33 | parser.process(app); | ||||
34 | | ||||
35 | if (!parser.positionalArguments().count()) { | ||||
36 | parser.showHelp(0); | ||||
37 | } | ||||
38 | | ||||
39 | if (KAutostart::isStartConditionMet(parser.positionalArguments().at(0))) { | ||||
40 | return 0; | ||||
41 | } else { | ||||
42 | return 255; | ||||
43 | } | ||||
44 | } |