From f8225a9ad3cce946c7cd26517bfe514e1f722d99 Mon Sep 17 00:00:00 2001 From: Jis G Jacob Date: Thu, 12 Mar 2026 10:11:19 +0530 Subject: [PATCH] Atoll: Fix Sleep Mode Icon Detections on Atoll Signed-off-by: Jis G Jacob --- DynamicIsland/managers/DoNotDisturbManager.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/DynamicIsland/managers/DoNotDisturbManager.swift b/DynamicIsland/managers/DoNotDisturbManager.swift index 518f37c..9e3aa14 100644 --- a/DynamicIsland/managers/DoNotDisturbManager.swift +++ b/DynamicIsland/managers/DoNotDisturbManager.swift @@ -740,7 +740,14 @@ extension FocusModeType { return } - // 2. macOS 26.3 custom Focus modes use `com.apple.donotdisturb.mode.`. + // 2. Sleep focus is reported as `com.apple.sleep.sleep-mode` by duetexpertd, + // not as the rawValue `com.apple.focus.sleep`, so handle it explicitly here. + if normalizedLowercased == "com.apple.sleep.sleep-mode" { + self = .sleep + return + } + + // 3. macOS custom Focus modes use `com.apple.donotdisturb.mode.`. // Must be checked BEFORE the generic prefix match, otherwise the prefix // `com.apple.donotdisturb.mode` would incorrectly resolve to .doNotDisturb. if normalizedLowercased.hasPrefix("com.apple.donotdisturb.mode.") { @@ -751,7 +758,7 @@ extension FocusModeType { } } - // 3. Prefix match for known built-in modes (e.g., com.apple.focus.personal-time -> .personal). + // 4. Prefix match for known built-in modes (e.g., com.apple.focus.personal-time -> .personal). if let resolved = FocusModeType.allCases.first(where: { guard !$0.rawValue.isEmpty else { return false } return normalized.hasPrefix($0.rawValue) || normalizedLowercased.hasPrefix($0.rawValue) @@ -760,7 +767,7 @@ extension FocusModeType { return } - // 4. Anything else under com.apple.focus is custom. + // 5. Anything else under com.apple.focus is custom. if normalizedLowercased.hasPrefix("com.apple.focus") { self = .custom return @@ -1276,6 +1283,7 @@ private enum FocusNotificationParsing { "(?i)(?:focusModeName|focusMode|displayName|name)\\s*=\\s*\"([^\"]+)\"", "(?i)(?:focusModeName|focusMode|displayName|name)\\s*=\\s*([^;\\n]+)", "activityDisplayName:\\s*([^;>\\n]+)", + "semanticType:\\s*([A-Za-z][A-Za-z0-9 _-]+)", "modeIdentifier:\\s*'com\\.apple\\.focus\\.([A-Za-z0-9._-]+)'" ] return patterns.compactMap { try? NSRegularExpression(pattern: $0, options: []) }