Created
March 4, 2009 06:06
-
-
Save daaku/73739 to your computer and use it in GitHub Desktop.
Idle number of seconds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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