Skip to content

Instantly share code, notes, and snippets.

@daaku
Created March 4, 2009 06:06
Show Gist options
  • Save daaku/73739 to your computer and use it in GitHub Desktop.
Save daaku/73739 to your computer and use it in GitHub Desktop.
Idle number of seconds.
/**
* Prints out the number of seconds since the last user input.
*
* gcc -framework Cocoa -o idle-seconds idle-seconds.m
*/
#import <Foundation/Foundation.h>
extern double CGSSecondsSinceLastInputEvent(unsigned long eventType);
int main (int argc, const char* argv[]) {
int idleTimeInSeconds = (int) CGSSecondsSinceLastInputEvent(-1);
printf("%d\n", idleTimeInSeconds);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment