macOS Darwin CoreFoundation - Is there a way to receive a callback if the brightness changes?

iOS has this notification that is triggered if the user or the system changes the brightness.


let noteCenter = NotificationCenter.default  
noteCenter.addObserver(self,  
    selector: #selector(brightnessDidChange),  
    name: UIScreen.brightnessDidChangeNotification,  
    object: nil)  
@objc func brightnessDidChange() { print(UIScreen.main.brightness) }


is there something like that for macOS?


Someone told me that this would be possible using CoreFoundation Callbacks, using "CFNotificationCenterAddObserver" but as expected, zero documentation on that can be found.


any ideas?

I have seen people post about using IOKit to get the brightness. In theory, you could combine that with an IOKit notification.

macOS Darwin CoreFoundation - Is there a way to receive a callback if the brightness changes?
 
 
Q