|
|
|
@ -88,8 +88,10 @@ parseCommandLine(InhibitAction *action)
|
|
|
|
|
"(defaults to \"%1\").").arg(action->reason), "reason");
|
|
|
|
|
parser.addOption(reasonOption);
|
|
|
|
|
|
|
|
|
|
parser.addPositionalArgument("command", "The command to run",
|
|
|
|
|
"command...");
|
|
|
|
|
parser.addPositionalArgument("command",
|
|
|
|
|
QString("The command to run "
|
|
|
|
|
"(defaults to \"%1\")").arg(action->command),
|
|
|
|
|
"[command...]");
|
|
|
|
|
|
|
|
|
|
if ( ! parser.parse(QCoreApplication::arguments()) )
|
|
|
|
|
die(1, parser.errorText());
|
|
|
|
@ -107,12 +109,10 @@ parseCommandLine(InhibitAction *action)
|
|
|
|
|
action->reason = parser.value(reasonOption);
|
|
|
|
|
|
|
|
|
|
QStringList args = parser.positionalArguments();
|
|
|
|
|
if ( args.size() > 1 ) {
|
|
|
|
|
if ( args.size() > 0 ) {
|
|
|
|
|
action->command = args.at(0);
|
|
|
|
|
action->arguments = args.mid(1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
die(1, "No command to run");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
@ -121,7 +121,8 @@ main(int argc, char **argv)
|
|
|
|
|
QCoreApplication app(argc, argv);
|
|
|
|
|
app.setApplicationName("pm-inhibit");
|
|
|
|
|
app.setApplicationVersion(VERSION);
|
|
|
|
|
InhibitAction action = { "pm-inhibit", "Per user request." };
|
|
|
|
|
InhibitAction action = { "pm-inhibit", "Per user request.", "/bin/sh",
|
|
|
|
|
QStringList() };
|
|
|
|
|
|
|
|
|
|
parseCommandLine(&action);
|
|
|
|
|
|
|
|
|
@ -130,6 +131,8 @@ main(int argc, char **argv)
|
|
|
|
|
die(1, "Cannot inhibit power management features");
|
|
|
|
|
|
|
|
|
|
QProcess process;
|
|
|
|
|
process.setInputChannelMode(QProcess::ForwardedInputChannel);
|
|
|
|
|
process.setProcessChannelMode(QProcess::ForwardedChannels);
|
|
|
|
|
process.start(action.command, action.arguments);
|
|
|
|
|
process.waitForFinished(-1);
|
|
|
|
|
|
|
|
|
|