Node.js/Electron - Can I reset the system idle time?

1

It's quite easy to get the system idle time in Electron with powerMonitor.getSystemIdleTime() However, I wonder if there is any easy way to reset this? I tried both the powerSaveBlocker.start('prevent-app-suspension') and the powerSaveBlocker.start('prevent-display-sleep') but they don't really reset the idle time.

When I use the Caffeine on the Mac OSX I noticed it works perfectly. It keeps reseting the system idle time.

Caffeine

Checked into the Caffeine source code. It's written in C#, not sure how can we make it in Node.js/Electron.

  internal static class NativeMethods {
    [DllImport("kernel32.dll")]
    public static extern uint SetThreadExecutionState(uint esFlags);
    public const uint ES_CONTINUOUS = 0x80000000;
    public const uint ES_SYSTEM_REQUIRED = 0x00000001;
    public const uint ES_DISPLAY_REQUIRED = 0x00000002;
  }

Any good ideas?

node.js
electron
asked on Stack Overflow Aug 28, 2020 by josephj • edited Aug 31, 2020 by josephj

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0