mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Add Suspend/Resume support (#1535)
* Add Suspend/Resume support * Support Suspend/Resume/Restart via API, UI and Systray * Support screen lock/unlock scenario * Handle idle scenario * Align with fix for #1368 * Update Windows build * Refactor SuspendHandler to maintain state * Do not start BG-Effect, if system goes into suspend mode * Correct Idle and Resume interaction
This commit is contained in:
@@ -251,6 +251,78 @@ QString JsonConnection::getSysInfo()
|
||||
return QString();
|
||||
}
|
||||
|
||||
void JsonConnection::suspend()
|
||||
{
|
||||
Info(_log, "Suspend Hyperion. Stop all instances and components");
|
||||
QJsonObject command;
|
||||
command["command"] = QString("system");
|
||||
command["subcommand"] = QString("suspend");
|
||||
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::resume()
|
||||
{
|
||||
Info(_log, "Resume Hyperion. Start all instances and components");
|
||||
QJsonObject command;
|
||||
command["command"] = QString("system");
|
||||
command["subcommand"] = QString("resume");
|
||||
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::toggleSuspend()
|
||||
{
|
||||
Info(_log, "Toggle between Suspend and Resume");
|
||||
QJsonObject command;
|
||||
command["command"] = QString("system");
|
||||
command["subcommand"] = QString("toggleSuspend");
|
||||
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::idle()
|
||||
{
|
||||
Info(_log, "Put Hyperion in Idle mode.");
|
||||
QJsonObject command;
|
||||
command["command"] = QString("system");
|
||||
command["subcommand"] = QString("idle");
|
||||
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::toggleIdle()
|
||||
{
|
||||
Info(_log, "Toggle between Idle and Working mode");
|
||||
QJsonObject command;
|
||||
command["command"] = QString("system");
|
||||
command["subcommand"] = QString("toggleIdle");
|
||||
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::restart()
|
||||
{
|
||||
Info(_log, "Restart Hyperion...");
|
||||
QJsonObject command;
|
||||
command["command"] = QString("system");
|
||||
command["subcommand"] = QString("restart");
|
||||
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::clear(int priority)
|
||||
{
|
||||
Debug(_log, "Clear priority channel [%d]", priority);
|
||||
|
@@ -99,6 +99,36 @@ public:
|
||||
///
|
||||
QString getSysInfo();
|
||||
|
||||
///
|
||||
/// Suspend Hyperion. Stop all instances and components
|
||||
///
|
||||
void suspend();
|
||||
|
||||
///
|
||||
/// Resume Hyperion. Start all instances and components
|
||||
///
|
||||
void resume();
|
||||
|
||||
///
|
||||
/// Toggle between Suspend and Resume
|
||||
///
|
||||
void toggleSuspend();
|
||||
|
||||
///
|
||||
/// Put Hyperion in Idle mode, i.e. all instances, components will be disabled besides the output processing (LED-devices, smoothing).
|
||||
///
|
||||
void idle();
|
||||
|
||||
///
|
||||
/// Toggle between Idle and Working mode
|
||||
///
|
||||
void toggleIdle();
|
||||
|
||||
///
|
||||
/// Restart Hyperion
|
||||
///
|
||||
void restart();
|
||||
|
||||
///
|
||||
/// Clear the given priority channel
|
||||
///
|
||||
|
@@ -119,8 +119,6 @@ int main(int argc, char * argv[])
|
||||
Option & argCreateEffect = parser.add<Option> (0x0, "createEffect" , "Write a new JSON Effect configuration file.\nFirst parameter = Effect name.\nSecond parameter = Effect file (--effectFile).\nLast parameter = Effect arguments (--effectArgs.)", "");
|
||||
Option & argDeleteEffect = parser.add<Option> (0x0, "deleteEffect" , "Delete a custom created JSON Effect configuration file.");
|
||||
#endif
|
||||
BooleanOption & argServerInfo = parser.add<BooleanOption>('l', "list" , "List server info and active effects with priority and duration");
|
||||
BooleanOption & argSysInfo = parser.add<BooleanOption>('s', "sysinfo" , "show system info");
|
||||
BooleanOption & argClear = parser.add<BooleanOption>('x', "clear" , "Clear data for the priority channel provided by the -p option");
|
||||
BooleanOption & argClearAll = parser.add<BooleanOption>(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
Option & argEnableComponent = parser.add<Option> ('E', "enable" , "Enable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, FORWARDER, BOBLIGHTSERVER, GRABBER, V4L, LEDDEVICE]");
|
||||
@@ -148,6 +146,14 @@ int main(int argc, char * argv[])
|
||||
BooleanOption & argConfigGet = parser.add<BooleanOption>(0x0, "configGet" , "Print the current loaded Hyperion configuration file");
|
||||
BooleanOption & argSchemaGet = parser.add<BooleanOption>(0x0, "schemaGet" , "Print the JSON schema for Hyperion configuration");
|
||||
Option & argConfigSet = parser.add<Option> (0x0, "configSet" , "Write to the actual loaded configuration file. Should be a JSON object string.");
|
||||
BooleanOption & argServerInfo = parser.add<BooleanOption>('l', "list" , "List server info and active effects with priority and duration");
|
||||
BooleanOption & argSysInfo = parser.add<BooleanOption>('s', "sysinfo" , "Show system info");
|
||||
BooleanOption & argSystemSuspend = parser.add<BooleanOption>(0x0, "suspend" , "Suspend Hyperion. Stop all instances and components");
|
||||
BooleanOption & argSystemResume = parser.add<BooleanOption>(0x0, "resume" , "Resume Hyperion. Start all instances and components");
|
||||
BooleanOption & argSystemToggleSuspend= parser.add<BooleanOption>(0x0, "toggleSuspend" , "Toggle between Suspend and Resume. First request will trigger suspend");
|
||||
BooleanOption & argSystemIdle = parser.add<BooleanOption>(0x0, "idle" , "Put Hyperion in Idle mode, i.e. all instances, components will be disabled besides the output processing (LED-devices, smoothing).");
|
||||
BooleanOption & argSystemToggleIdle = parser.add<BooleanOption>(0x0, "toggleIdle" , "Toggle between Idle and Working mode. First request will trigger Idle mode");
|
||||
BooleanOption & argSystemRestart = parser.add<BooleanOption>(0x0, "restart" , "Restart Hyperion");
|
||||
|
||||
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print", "Print the JSON input and output messages on stdout");
|
||||
BooleanOption & argDebug = parser.add<BooleanOption>(0x0, "debug", "Enable debug logging");
|
||||
@@ -178,9 +184,13 @@ int main(int argc, char * argv[])
|
||||
#if defined(ENABLE_EFFECTENGINE)
|
||||
parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
|
||||
#endif
|
||||
parser.isSet(argServerInfo), parser.isSet(argSysInfo),parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
|
||||
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argOff), parser.isSet(argOn), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
|
||||
parser.isSet(argMapping),parser.isSet(argVideoMode) });
|
||||
parser.isSet(argServerInfo), parser.isSet(argSysInfo),
|
||||
parser.isSet(argSystemSuspend), parser.isSet(argSystemResume), parser.isSet(argSystemToggleSuspend),
|
||||
parser.isSet(argSystemIdle), parser.isSet(argSystemToggleIdle),
|
||||
parser.isSet(argSystemRestart),
|
||||
parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
|
||||
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argOff), parser.isSet(argOn), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
|
||||
parser.isSet(argMapping),parser.isSet(argVideoMode) });
|
||||
if (commandCount != 1)
|
||||
{
|
||||
qWarning() << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:";
|
||||
@@ -193,6 +203,12 @@ int main(int argc, char * argv[])
|
||||
#endif
|
||||
showHelp(argServerInfo);
|
||||
showHelp(argSysInfo);
|
||||
showHelp(argSystemSuspend);
|
||||
showHelp(argSystemResume);
|
||||
showHelp(argSystemToggleSuspend);
|
||||
showHelp(argSystemIdle);
|
||||
showHelp(argSystemToggleIdle);
|
||||
showHelp(argSystemRestart);
|
||||
showHelp(argClear);
|
||||
showHelp(argClearAll);
|
||||
showHelp(argEnableComponent);
|
||||
@@ -295,6 +311,30 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
std::cout << "System info:\n" << connection.getSysInfo().toStdString() << std::endl;
|
||||
}
|
||||
else if (parser.isSet(argSystemSuspend))
|
||||
{
|
||||
connection.suspend();
|
||||
}
|
||||
else if (parser.isSet(argSystemResume))
|
||||
{
|
||||
connection.resume();
|
||||
}
|
||||
else if (parser.isSet(argSystemToggleSuspend))
|
||||
{
|
||||
connection.toggleSuspend();
|
||||
}
|
||||
else if (parser.isSet(argSystemIdle))
|
||||
{
|
||||
connection.idle();
|
||||
}
|
||||
else if (parser.isSet(argSystemToggleIdle))
|
||||
{
|
||||
connection.toggleIdle();
|
||||
}
|
||||
else if (parser.isSet(argSystemRestart))
|
||||
{
|
||||
connection.restart();
|
||||
}
|
||||
else if (parser.isSet(argClear))
|
||||
{
|
||||
connection.clear(argPriority.getInt(parser));
|
||||
|
Reference in New Issue
Block a user