From 75093e79bdb890939b0432ff8a5e328e87d341c0 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Sun, 10 Aug 2025 11:28:43 +0545 Subject: [PATCH] Wildcard Matching for Default Power Mode. --- VoiceInk/PowerMode/ActiveWindowService.swift | 4 ++++ VoiceInk/PowerMode/PowerModeConfig.swift | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/VoiceInk/PowerMode/ActiveWindowService.swift b/VoiceInk/PowerMode/ActiveWindowService.swift index e5038d4..1a3cc0a 100644 --- a/VoiceInk/PowerMode/ActiveWindowService.swift +++ b/VoiceInk/PowerMode/ActiveWindowService.swift @@ -52,6 +52,10 @@ class ActiveWindowService: ObservableObject { configToApply = PowerModeManager.shared.getConfigurationForApp(bundleIdentifier) } + if configToApply == nil { + configToApply = PowerModeManager.shared.getWildcardConfiguration() + } + if let config = configToApply { await MainActor.run { PowerModeManager.shared.setActiveConfiguration(config) diff --git a/VoiceInk/PowerMode/PowerModeConfig.swift b/VoiceInk/PowerMode/PowerModeConfig.swift index 3cb2a6a..80a68ab 100644 --- a/VoiceInk/PowerMode/PowerModeConfig.swift +++ b/VoiceInk/PowerMode/PowerModeConfig.swift @@ -204,6 +204,17 @@ class PowerModeManager: ObservableObject { return nil } + func getWildcardConfiguration() -> PowerModeConfig? { + for config in configurations.filter({ $0.isEnabled }) { + if let urlConfigs = config.urlConfigs { + if urlConfigs.contains(where: { $0.url == "*" }) { + return config + } + } + } + return nil + } + func enableConfiguration(with id: UUID) { if let index = configurations.firstIndex(where: { $0.id == id }) { configurations[index].isEnabled = true