Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically check state of do not disturb on OS X

Using Objective-C, how can I programmatically check the state of the system "Do Not Disturb" setting on OS X? I'm fine with using hacks or private APIs since I don't need to submit to the Mac App Store.

like image 627
Erik Avatar asked Oct 11 '14 05:10

Erik


1 Answers

In Objective-C, you can access the value like this:

NSUserDefaults* defaults = [[NSUserDefaults alloc]initWithSuiteName:@"com.apple.notificationcenterui"];
BOOL dnd = [defaults boolForKey:@"doNotDisturb"];
like image 196
eskimwier Avatar answered Sep 18 '22 19:09

eskimwier