Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suspend and shutdown options to screensaver #29

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions es-app/src/SystemScreenSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "BrightnessControl.h"
#include "ImageIO.h"
#include "utils/Randomizer.h"
#include "platform.h"

#define FADE_TIME 500

Expand Down Expand Up @@ -183,6 +184,15 @@ void SystemScreenSaver::startScreenSaver()
// No videos. Just use a standard screensaver
mState = STATE_SCREENSAVER_ACTIVE;
mCurrentGame = NULL;

if (screensaver_behavior == "suspend")
{
runSystemCommand("/usr/bin/systemctl suspend", "", nullptr);
}
else if (screensaver_behavior == "shutdown")
{
runSystemCommand("/usr/bin/systemctl poweroff", "", nullptr);
}
}

void SystemScreenSaver::stopScreenSaver()
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/guis/GuiGeneralScreensaverOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, int s

// Screensaver behavior
auto ctlBehavior = std::make_shared< OptionListComponent<std::string> >(mWindow, _("SCREENSAVER TYPE"), false);
ctlBehavior->addRange({ "dim", "black", "random video", "slideshow" }, ssBehavior);
ctlBehavior->addRange({ "dim", "black", "random video", "slideshow", "suspend", "shutdown" }, ssBehavior);
addWithLabel(_("SCREENSAVER TYPE"), ctlBehavior, selectItem == 1);
ctlBehavior->setSelectedChangedCallback([this](const std::string& name)
{
Expand Down