Skip to content

Instantly share code, notes, and snippets.

@dlmanning
Created June 15, 2021 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlmanning/3a0bf392831be53412bca9a0215d3b9a to your computer and use it in GitHub Desktop.
Save dlmanning/3a0bf392831be53412bca9a0215d3b9a to your computer and use it in GitHub Desktop.
read whether or not macOS's Do Not Disturb mode is on
#include <CoreFoundation/CoreFoundation.h>
#include <stdio.h>
int main()
{
CFStringRef DO_NOT_DISTURB = CFStringCreateWithCString(kCFAllocatorDefault, "doNotDisturb", kCFStringEncodingUTF8);
CFStringRef APP_ID = CFStringCreateWithCString(kCFAllocatorDefault, "com.apple.notificationcenterui", kCFStringEncodingUTF8);
Boolean keyExists;
Boolean result;
result = CFPreferencesGetAppBooleanValue(DO_NOT_DISTURB, APP_ID, &keyExists);
if (result)
{
printf("on\n");
}
else
{
printf("off\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment