Commit 808aaafc authored by Gabriel Souza Franco's avatar Gabriel Souza Franco

[systemd] Fix start-condition helper

Systemd passes the condition as `--condition <cond>`, not as a positional argument.
Also switch around return codes, 255 is special-cased to mean that the unit has failed.
parent 4fd910bb
......@@ -28,17 +28,19 @@ int main(int argc, char **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'"));
QCommandLineOption option{QStringLiteral("condition"),
QStringLiteral("start condition, in the format 'rcfile:group:entry:default'."),
QStringLiteral("condition")};
parser.addOption(option);
parser.process(app);
if (!parser.positionalArguments().count()) {
parser.showHelp(0);
if (!parser.isSet(option)) {
parser.showHelp(255);
}
if (KAutostart::isStartConditionMet(parser.positionalArguments().at(0))) {
if (KAutostart::isStartConditionMet(parser.value(option))) {
return 0;
} else {
return 255;
return 1;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment