Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

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