Atoll: Fix Sleep Mode Icon Detections on Atoll

Signed-off-by: Jis G Jacob <studiokeys@blissroms.org>
This commit is contained in:
Jis G Jacob 2026-03-12 10:11:19 +05:30
commit f8225a9ad3

View file

@ -740,7 +740,14 @@ extension FocusModeType {
return
}
// 2. macOS 26.3 custom Focus modes use `com.apple.donotdisturb.mode.<symbol>`.
// 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.<symbol>`.
// 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: []) }