From a29f73a99bdc2c170933a32959a7dd9bfcef069a Mon Sep 17 00:00:00 2001 From: Hariharan Mudaliar Date: Sat, 20 Dec 2025 15:01:42 +0530 Subject: [PATCH] Update settings and headphone mute condition --- .../components/Settings/SettingsView.swift | 1 + .../managers/SystemChangesObserver.swift | 35 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/DynamicIsland/components/Settings/SettingsView.swift b/DynamicIsland/components/Settings/SettingsView.swift index 6efbd60..daa5df6 100644 --- a/DynamicIsland/components/Settings/SettingsView.swift +++ b/DynamicIsland/components/Settings/SettingsView.swift @@ -2294,6 +2294,7 @@ struct About: View { .padding(.horizontal, 10) } .frame(maxWidth: .infinity, alignment: .center) + .background(Color(nsColor: .controlBackgroundColor)) } .toolbar { // Button("Welcome window") { diff --git a/DynamicIsland/managers/SystemChangesObserver.swift b/DynamicIsland/managers/SystemChangesObserver.swift index c62cb11..4eeed2f 100644 --- a/DynamicIsland/managers/SystemChangesObserver.swift +++ b/DynamicIsland/managers/SystemChangesObserver.swift @@ -10,6 +10,14 @@ final class SystemChangesObserver: MediaKeyInterceptorDelegate { private let keyboardBacklightController = SystemKeyboardBacklightController.shared private let mediaKeyInterceptor = MediaKeyInterceptor.shared + private static let headsetIconSymbols: Set = [ + "airpods", + "airpodspro", + "airpodsmax", + "beats.headphones", + "headphones" + ] + private let standardVolumeStep: Float = 1.0 / 16.0 private let standardBrightnessStep: Float = 1.0 / 16.0 private let fineStepDivisor: Float = 4.0 @@ -30,11 +38,16 @@ final class SystemChangesObserver: MediaKeyInterceptorDelegate { volumeController.onVolumeChange = { [weak self] volume, muted in guard let self, self.volumeEnabled else { return } let value = muted ? 0 : volume - self.sendVolumeNotification(value: value) + Task { @MainActor in + self.sendVolumeNotification(value: value, isMuted: muted) + } } volumeController.onRouteChange = { [weak self] in guard let self, self.volumeEnabled else { return } - self.sendVolumeNotification(value: self.volumeController.isMuted ? 0 : self.volumeController.currentVolume) + let muted = self.volumeController.isMuted + Task { @MainActor in + self.sendVolumeNotification(value: muted ? 0 : self.volumeController.currentVolume, isMuted: muted) + } } volumeController.start() @@ -162,7 +175,8 @@ final class SystemChangesObserver: MediaKeyInterceptorDelegate { // MARK: - HUD Dispatch - private func sendVolumeNotification(value: Float) { + @MainActor + private func sendVolumeNotification(value: Float, isMuted: Bool) { if HUDSuppressionCoordinator.shared.shouldSuppressVolumeHUD { return } @@ -177,10 +191,8 @@ final class SystemChangesObserver: MediaKeyInterceptorDelegate { // Send to Vertical HUD if enabled if Defaults[.enableVerticalHUD] { - Task { @MainActor in - let icon = BluetoothAudioManager.shared.activeDeviceIconSymbol() ?? "" - VerticalHUDWindowManager.shared.show(type: .volume, value: CGFloat(value), icon: icon) - } + let icon = resolvedVolumeIcon(isMuted: isMuted) + VerticalHUDWindowManager.shared.show(type: .volume, value: CGFloat(value), icon: icon) return } @@ -205,6 +217,15 @@ final class SystemChangesObserver: MediaKeyInterceptorDelegate { } } + @MainActor + private func resolvedVolumeIcon(isMuted: Bool) -> String { + guard let icon = BluetoothAudioManager.shared.activeDeviceIconSymbol() else { return "" } + if isMuted && Self.headsetIconSymbols.contains(icon) { + return "headphones.slash" + } + return icon + } + private func sendBrightnessNotification(value: Float) { // Send to Circular HUD if enabled if Defaults[.enableCircularHUD] {