diff --git a/src/lib/platform/EiScreen.cpp b/src/lib/platform/EiScreen.cpp index ca1c8367f..6350a5545 100644 --- a/src/lib/platform/EiScreen.cpp +++ b/src/lib/platform/EiScreen.cpp @@ -14,6 +14,7 @@ #include "base/Log.h" #include "base/Stopwatch.h" #include "common/Constants.h" +#include "deskflow/App.h" #include "deskflow/Clipboard.h" #include "deskflow/KeyMap.h" #include "deskflow/ScreenException.h" @@ -73,6 +74,11 @@ EiScreen::EiScreen(bool isPrimary, IEventQueue *events, bool usePortal, deskflow throw std::runtime_error("failed to init ei context"); } } + + // disable sleep if the flag is set + if (App::instance().argsBase().m_preventSleep) { + m_powerManager.disableSleep(); + } } EiScreen::~EiScreen() diff --git a/src/lib/platform/EiScreen.h b/src/lib/platform/EiScreen.h index 3c7e88c1b..0a615815e 100644 --- a/src/lib/platform/EiScreen.h +++ b/src/lib/platform/EiScreen.h @@ -9,6 +9,7 @@ #include "deskflow/KeyMap.h" #include "deskflow/PlatformScreen.h" +#include "platform/XWindowsPowerManager.h" #include #include @@ -188,6 +189,8 @@ private: using HotKeyMap = std::map; HotKeyMap m_hotkeys; + // Despite the name XWindowsPowerManager, this works on Wayland too + XWindowsPowerManager m_powerManager; }; } // namespace deskflow