Skip to content

Pototoooo/InputDeviceGuard

Repository files navigation

InputDeviceGuard icon

InputDeviceGuard

English · 简体中文

Keep your Mac's built-in microphone selected while Bluetooth headphones stay in high-quality A2DP output mode.

Build MIT License macOS 13+

The problem

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.

Features

  • 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.mainApp for 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.

Privacy

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.

Requirements

  • macOS 13 Ventura or later.
  • Xcode or Xcode Command Line Tools with Swift.

Install command-line tools if needed:

xcode-select --install

Install from source

git clone https://github.com/Pototoooo/InputDeviceGuard.git
cd InputDeviceGuard
./install.sh

The installer:

  1. Compiles the Swift source locally.
  2. Generates a multi-resolution .icns file.
  3. Creates and ad-hoc signs /Applications/InputDeviceGuard.app.
  4. Registers the app with SMAppService for login startup.
  5. Launches the menu-bar app.

No prebuilt binary is downloaded or executed.

Use

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.

Diagnostics

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.

Uninstall

Choose 卸载麦克风守护… from the menu-bar menu, or run:

./uninstall.sh

Both paths unregister login startup and move the application to Trash.

Build manually

mkdir -p build
xcrun swiftc -O \
  -framework CoreAudio \
  -framework AppKit \
  -framework ServiceManagement \
  Sources/InputDeviceGuard.swift \
  -o build/InputDeviceGuard

Project layout

Assets/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

Contributing

See CONTRIBUTING.md. Bug reports and focused pull requests are welcome, especially for additional Bluetooth devices and macOS versions.

License

MIT

About

A native macOS menu-bar utility that keeps Bluetooth headphones in A2DP by protecting the built-in microphone route.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages