Skip to content

Commit 88e85bb

Browse files
authored
macos: add screenlock example (#202)
1 parent afd1efc commit 88e85bb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

macos/_examples/screenlock/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"github.com/progrium/macdriver/macos"
7+
"github.com/progrium/macdriver/macos/appkit"
8+
"github.com/progrium/macdriver/macos/foundation"
9+
)
10+
11+
func main() {
12+
macos.RunApp(func(app appkit.Application, delegate *appkit.ApplicationDelegate) {
13+
dnc := foundation.DistributedNotificationCenter_NotificationCenterForType(foundation.LocalNotificationCenterType)
14+
dnc.AddObserverForNameObjectQueueUsingBlock("com.apple.screenIsLocked", nil, foundation.OperationQueue_MainQueue(), func(notification foundation.Notification) {
15+
log.Println("screen is locked")
16+
})
17+
dnc.AddObserverForNameObjectQueueUsingBlock("com.apple.screenIsUnlocked", nil, foundation.OperationQueue_MainQueue(), func(notification foundation.Notification) {
18+
log.Println("screen is unlocked")
19+
})
20+
})
21+
}

0 commit comments

Comments
 (0)