Checking for doNotDisturb

Hello,

I'm trying to check the doNotDisturb attribute in com.apple.notificationcenterui, but I have been unsuccesful in my attempts. I have tried using NSUserDefaults and I have tried CFPreferences. If I run "defaults -currentHost read com.apple.notificationcenterui" from the command line I see the result, but not from code. Does someone have an example of this working?


Thanks

Charles

Accepted Reply

Seems there is no API to do this.


h ttps://stackoverflow.com/questions/17560765/how-can-i-detect-dnd-mode-within-an-app


But, you could probably execute the terminal command from within the app ?

h ttps://stackoverflow.com/questions/412562/execute-a-terminal-command-from-a-cocoa-app

Replies

Seems there is no API to do this.


h ttps://stackoverflow.com/questions/17560765/how-can-i-detect-dnd-mode-within-an-app


But, you could probably execute the terminal command from within the app ?

h ttps://stackoverflow.com/questions/412562/execute-a-terminal-command-from-a-cocoa-app

Yeah, it's a shame. The feature is there so it would be nice if we could take advantage of it.


So it looks like I will need to use NSTask with defaults to get the desired value. It should be possible via CFPreferences but I'm unable to get the value.


Thanks for the help!

Wish you success.


And don't forget to close the thread if that works.