diff --git a/src/modules/espresso/Espresso/Core/APIHelper.cs b/src/modules/espresso/Espresso/Core/APIHelper.cs index fae3d4733f..e589ba951b 100644 --- a/src/modules/espresso/Espresso/Core/APIHelper.cs +++ b/src/modules/espresso/Espresso/Core/APIHelper.cs @@ -38,6 +38,7 @@ namespace Espresso.Shell.Core [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags); + // More details about the API used: https://docs.microsoft.com/windows/win32/api/shellapi/nf-shellapi-extracticonexw [DllImport("Shell32.dll", EntryPoint = "ExtractIconExW", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] private static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons); @@ -74,13 +75,23 @@ namespace Espresso.Shell.Core return false; } } - + + /// + /// Attempts to reset the current machine state to one where Espresso doesn't try to keep it awake. + /// This does not interfere with the state that can be potentially set by other applications. + /// + /// Status of the attempt. True is successful, false if not. public static bool SetNormalKeepAwake() { TokenSource.Cancel(); return SetAwakeState(EXECUTION_STATE.ES_CONTINUOUS); } + /// + /// Sets up the machine to be awake indefinitely. + /// + /// Determines whether the display should be kept on while the machine is awake. + /// Status of the attempt. True if successful, false if not. public static bool SetIndefiniteKeepAwake(bool keepDisplayOn = true) { if (keepDisplayOn)