Skip to content

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

@nickav

Description

@nickav

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions