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

Idle time on macOS Sierra doesn't account for keyboard input #5

Open
nickav opened this issue Nov 8, 2016 · 1 comment
Open

Idle time on macOS Sierra doesn't account for keyboard input #5

nickav opened this issue Nov 8, 2016 · 1 comment

Comments

@nickav
Copy link

nickav commented Nov 8, 2016

The idle time on macOS Sierra doesn't get reset when on macOS Sierra. I switched the Mac native plugin to use the following script and now idle time gets reset when you type as it should.

#import <CoreFoundation/CoreFoundation.h>
#import <AppKit/AppKit.h>

/**
 Returns the number of seconds the machine has been idle or -1 if an error occurs.
 The code is compatible with Tiger/10.4 and later (but not iOS).
 */
int32_t SystemIdleTime(void) {
  double idleSeconds = CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateHIDSystemState, kCGAnyInputEventType);
  return (int32_t) (idleSeconds * 1000);
}
@ankur1163
Copy link

can you guide me how to use this thing? There is no documentation on this module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants