Wildcard Matching for Default Power Mode.
This commit is contained in:
parent
cad3b6b460
commit
75093e79bd
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user