Add opt-in override for standard volume media keys.

Keep the current safety behavior by default, but allow advanced users to force-capture standard volume media keys even when macOS output volume is controllable.

Made-with: Cursor
This commit is contained in:
shuntagami 2026-03-22 17:00:00 +09:00
parent fc19ce2bd2
commit fa5a345b04
2 changed files with 5 additions and 2 deletions

View file

@ -78,6 +78,9 @@ enum PrefKey: String {
// Use fine OSD scale for volume
case useFineScaleVolume
// Always capture standard volume media keys even when macOS output volume is controllable
case forceStandardVolumeMediaKeys
// Use smoothBrightness
case disableSmoothBrightness

View file

@ -166,8 +166,8 @@ class MediaKeyTapManager: MediaKeyTapDelegate {
let keysToDelete: [MediaKey] = [.brightnessUp, .brightnessDown]
keys.removeAll { keysToDelete.contains($0) }
}
// Remove volume related keys if audio device is controllable
if let defaultAudioDevice = app.coreAudio.defaultOutputDevice {
// Remove volume related keys if audio device is controllable unless the user opted into force-capturing them.
if !prefs.bool(forKey: PrefKey.forceStandardVolumeMediaKeys.rawValue), let defaultAudioDevice = app.coreAudio.defaultOutputDevice {
let keysToDelete: [MediaKey] = [.volumeUp, .volumeDown, .mute]
if prefs.integer(forKey: PrefKey.multiKeyboardVolume.rawValue) == MultiKeyboardVolume.audioDeviceNameMatching.rawValue {
if DisplayManager.shared.updateAudioControlTargetDisplays(deviceName: defaultAudioDevice.name) == 0 {