如何永久固定2013款MacBook Pro麦克风输入?求切换脚本方案
我之前折腾过Mac音频设备的自动切换问题,刚好能帮到你!下面分两个部分给你解决方案:
一、永久设置内置麦克风为默认输入设备
蓝牙设备连接时系统自动切换输入源是默认行为,要强制锁定内置麦克风,可以试试这两种方法:
1. 系统设置GUI(基础版)
- 打开「系统设置」(老系统是「系统偏好设置」),找到「声音」选项
- 切换到「输入」标签页,选中「内置麦克风」
- 点击窗口左下角的锁图标,输入密码解锁设置,确保这个选择不会被随意修改
注意:部分系统版本中,蓝牙设备连接时仍可能自动覆盖这个设置,所以更可靠的是用终端命令强制锁定。
2. 终端命令(稳定版)
通过命令行直接修改系统音频配置,能更稳定地锁定默认输入设备:
- 先获取内置麦克风的唯一标识UID:
执行后会得到一串类似system_profiler SPAudioDataType | grep -A 15 "内置麦克风" | grep "UID" | awk -F ": " '{print $2}'BuiltInMicrophoneDevice的字符串,记下来。 - 设置默认输入设备:
defaults write com.apple.audio.CoreAudio "DefaultInputDevice" -string "你的UID" - (可选)重启音频服务让设置立即生效:
输入你的用户密码即可,这个命令会重启音频进程,不会影响系统其他功能。sudo killall coreaudiod
二、用AppleScript或Alfred Workflow实现快速切换
如果需要手动快速切换回内置麦克风,这两个方案很实用:
1. AppleScript脚本
可以写一个脚本直接控制系统设置切换输入设备,适配不同系统版本:
适用于Ventura及以后版本的脚本:
set targetDevice to "内置麦克风" tell application "System Settings" to activate delay 0.3 tell application "System Events" tell process "System Settings" click menu item "声音" of menu "显示" of menu bar 1 delay 0.5 click radio button "输入" of tab group 1 of window "声音" delay 0.5 select (row where value of text field 1 is targetDevice) of table 1 of scroll area 1 of tab group 1 of window "声音" end tell end tell tell application "System Settings" to quit
适用于Monterey及以前版本的脚本:
set targetDevice to "内置麦克风" tell application "System Preferences" activate set current pane to pane id "com.apple.preference.sound" tell application "System Events" tell tab group 1 of window "声音" of application process "System Preferences" click radio button "输入" select (row where value of text field 1 is targetDevice) of table 1 of scroll area 1 end tell end tell quit end tell
把脚本保存为 .app 文件,双击就能快速切换,也可以绑定系统快捷键。
2. Alfred Workflow(高效快捷版)
用Alfred实现一键切换,步骤如下:
- 打开Alfred偏好设置,进入「Workflows」标签
- 点击左下角「+」,选择「Blank Workflow」,命名为「切换至内置麦克风」
- 添加一个「Hotkey」触发器(比如设置为
Ctrl+Shift+M) - 添加一个「Run Script」动作,选择「AppleScript」,把上面对应系统版本的脚本粘贴进去
- 保存后,按下设置的快捷键就能瞬间切换到内置麦克风
进阶技巧:可以用终端命令替代AppleScript,避免UI模拟的不稳定问题,把「Run Script」的脚本换成:
DEVICE_UID=$(system_profiler SPAudioDataType | grep -A 15 "内置麦克风" | grep "UID" | awk -F ": " '{print $2}') defaults write com.apple.audio.CoreAudio "DefaultInputDevice" -string "$DEVICE_UID"这种方式更高效,不需要打开系统设置窗口。
内容的提问来源于stack exchange,提问作者random-forest-cat
相关产品推荐
相关产品推荐

