How do i use this library to get lock/unlocked information of macos desktop #102
Unanswered
avaidhyajc
asked this question in
Q&A
Replies: 2 comments
-
|
@progrium Request your expertise on this please |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Sorry it took a while. There is now a better version of macdriver that lets you do this pretty easily. I even made it one of the builtin examples: package main
import (
"log"
"github.com/progrium/macdriver/macos"
"github.com/progrium/macdriver/macos/appkit"
"github.com/progrium/macdriver/macos/foundation"
)
func main() {
macos.RunApp(func(app appkit.Application, delegate *appkit.ApplicationDelegate) {
dnc := foundation.DistributedNotificationCenter_NotificationCenterForType(foundation.LocalNotificationCenterType)
dnc.AddObserverForNameObjectQueueUsingBlock("com.apple.screenIsLocked", nil, foundation.OperationQueue_MainQueue(), func(notification foundation.Notification) {
log.Println("screen is locked")
})
dnc.AddObserverForNameObjectQueueUsingBlock("com.apple.screenIsUnlocked", nil, foundation.OperationQueue_MainQueue(), func(notification foundation.Notification) {
log.Println("screen is unlocked")
})
})
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
From web-surfing , i came across posts that recommended listening to notification events on macos for display login/logout

Can someone please help on how can i achieve this in go using macdriver ?
Beta Was this translation helpful? Give feedback.
All reactions