Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Naming changes to fit it with Focus feature
  • Loading branch information
Rubén committed Nov 11, 2021
commit 64a0acc0cd8a69b7299c263eb1877f01ccee2bf7
2 changes: 1 addition & 1 deletion lib/dnd/monterey-macos-dnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
+ (bool)isEnabled;
+ (bool)enabledByAssertion;
+ (bool)enabledBySchedule;
+ (NSString*)getFocusMode;
+ (NSString*)getActiveFocusMode;
+ (bool)allowedForBundleId;
+ (NSDictionary*)readJSONData:(NSString*)filePath;
@end
16 changes: 8 additions & 8 deletions lib/dnd/monterey-macos-dnd.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ + (bool)isEnabled {
// ModeConfigurationSecure.json - Contains Apps allowed in DND mode

// 1. check assertion
bool isDNDEnabled = [self enabledByAssertion];
bool isFocusModeEnabled = [self enabledByAssertion];

if (!isDNDEnabled) {
if (!isFocusModeEnabled) {
// 2. check schedule config
isDNDEnabled = [self enabledBySchedule];
isFocusModeEnabled = [self enabledBySchedule];
}

if (isDNDEnabled) {
if (isFocusModeEnabled) {
// 3 additional check is bundleIdentifier allowed while DND is on
bool isBundleIdAllowedInDND = [self allowedForBundleId];
// DND is "off" for current application
return !isBundleIdAllowedInDND;
}
return isDNDEnabled;
return isFocusModeEnabled;
}

+ (bool)allowedForBundleId {
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];

if (bundleIdentifier) {
NSString *focusMode = [self getFocusMode];
NSString *focusMode = [self getActiveFocusMode];
NSDictionary *modeConfigSecureDict =
[self readJSONData:
@"~/Library/DoNotDisturb/DB/ModeConfigurationsSecure.json"];
Expand Down Expand Up @@ -57,7 +57,7 @@ + (bool)allowedForBundleId {
return false;
}

+ (NSString *)getFocusMode {
+ (NSString *)getActiveFocusMode {
NSDictionary *assertDict =
[self readJSONData:@"~/Library/DoNotDisturb/DB/Assertions.json"];

Expand Down Expand Up @@ -132,7 +132,7 @@ + (bool)enabledBySchedule {
NSDictionary *modeConfigDict =
[self readJSONData:@"~/Library/DoNotDisturb/DB/ModeConfigurations.json"];

NSString *focusMode = [self getFocusMode];
NSString *focusMode = [self getActiveFocusMode];
bool hasActiveTrigger = false;
NSArray *triggers = [[[[[[modeConfigDict valueForKey:@"data"] objectAtIndex:0]
valueForKey:@"modeConfigurations"]
Expand Down