Created
October 3, 2017 14:44
-
-
Save koenbollen/2f4dfed6a21347dd758b273abcde7ae4 to your computer and use it in GitHub Desktop.
Golang example of detecting user activity (using CGEventSourceSecondsSinceLastEventType from CoreGraphics)
This file contains hidden or 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
package main | |
// #cgo LDFLAGS: -framework CoreGraphics | |
// #include <CoreGraphics/CoreGraphics.h> | |
import "C" | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
// Returns the number of seconds a osx user is idle! | |
result := C.CGEventSourceSecondsSinceLastEventType(1, math.MaxInt32) | |
fmt.Println(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment