Created
June 15, 2021 03:45
-
-
Save dlmanning/3a0bf392831be53412bca9a0215d3b9a to your computer and use it in GitHub Desktop.
read whether or not macOS's Do Not Disturb mode is on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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