English · 简体中文
Keep your Mac's built-in microphone selected while Bluetooth headphones stay in high-quality A2DP output mode.
macOS may temporarily choose a newly connected Bluetooth headset as the default input device. An app that initializes an input audio engine can then cause the headset to switch from stereo A2DP output to HFP/SCO call mode, reducing output quality even when the user did not intentionally choose the headset microphone.
InputDeviceGuard keeps the default input on the physical Mac microphone and never changes the default output.
- Native, lightweight macOS menu-bar app.
- Watches CoreAudio default-input and device-list changes.
- Identifies the physical built-in microphone by transport and stable UID.
- Reacts immediately and retries briefly to outlast transient Bluetooth routing.
- Shows current input, output, and an A2DP/HFP quality indicator.
- Temporarily allows the headset microphone for 15 minutes, one hour, or the current login session.
- Uses
SMAppService.mainAppfor a visible, user-controlled login item. - Provides direct access to Sound settings, Login Items, logs, and uninstall.
- Moves the app to Trash during in-app uninstall instead of deleting it permanently.
- Prevents duplicate GUI instances.
InputDeviceGuard does not record, capture, process, or transmit microphone audio. It does not request microphone permission. It only reads CoreAudio device metadata and writes the system default-input device property.
The app has no analytics, network client, update service, or external runtime dependency.
- macOS 13 Ventura or later.
- Xcode or Xcode Command Line Tools with Swift.
Install command-line tools if needed:
xcode-select --installgit clone https://github.com/Pototoooo/InputDeviceGuard.git
cd InputDeviceGuard
./install.shThe installer:
- Compiles the Swift source locally.
- Generates a multi-resolution
.icnsfile. - Creates and ad-hoc signs
/Applications/InputDeviceGuard.app. - Registers the app with
SMAppServicefor login startup. - Launches the menu-bar app.
No prebuilt binary is downloaded or executed.
Click the microphone icon in the menu bar. The menu provides:
- Protect Built-in Microphone — enable or disable enforcement.
- Restore Mac Microphone Now — immediately restore the built-in input.
- Temporarily Use Headset Microphone — pause for 15 minutes, one hour, or the current login session.
- Launch at Login — register or unregister the visible macOS login item.
- Shortcuts to Sound settings, Login Items, diagnostic logs, and Finder.
- Recoverable uninstall.
The UI currently uses Simplified Chinese labels. Contributions adding other localizations are welcome.
APP="/Applications/InputDeviceGuard.app/Contents/MacOS/InputDeviceGuard"
"$APP" --status
"$APP" --login-status
"$APP" --once
tail -f "$HOME/Library/Logs/InputDeviceGuard/guard.log"HFP/SCO detection is based on the active Bluetooth output's channel count and nominal sample rate. It is a status heuristic; route enforcement itself does not depend on that heuristic.
Choose 卸载麦克风守护… from the menu-bar menu, or run:
./uninstall.shBoth paths unregister login startup and move the application to Trash.
mkdir -p build
xcrun swiftc -O \
-framework CoreAudio \
-framework AppKit \
-framework ServiceManagement \
Sources/InputDeviceGuard.swift \
-o build/InputDeviceGuardAssets/AppIcon-1024.png App icon source
Sources/InputDeviceGuard.swift CoreAudio guard and menu-bar UI
install.sh Local app-bundle builder and installer
make-icon.sh ICNS generator
uninstall.sh Recoverable command-line uninstall
See CONTRIBUTING.md. Bug reports and focused pull requests are welcome, especially for additional Bluetooth devices and macOS versions.