I'm trying to execute a method when the system volume changes.
I've tried using
DistributedNotificationCenter.default().addObserver(self,selector: #selector(volumeChanged(_:)),name: NSNotification.Name(rawValue: "com.apple.sound.settingsChangedNotification"),object: nil)
but it didn't work.
Well, it does work. But only if the System Preferences app is open.
What's the right way to accomplish this task?
Ps: note that it's on MacOS, not iOS