自从升级到Big Sur, 之前常用的连接Airpods的Alfred 脚本就不好用了. 而Big Sur 自动连接Airpods的功能并不好用, 还是手动更靠谱了.
搜索了很多文章更新了脚本, 话不多说, 直接上代码吧:
on alfred_script(q)
activate application "SystemUIServer"
# AppleScript
set AirPodsName to "2Pods"
tell application "System Events"
tell application process "ControlCenter"
set btMenu to menu bar item "蓝牙" of menu bar 1
tell btMenu to click
# entire contents
set btCheckbox to checkbox 1 of scroll area 1 of group 1 of window "控制中心" whose title contains AirPodsName
# entire contents
if exists btCheckbox then
if value of btCheckbox is 1 then
set btCheckboxValue to 0
tell btCheckbox to click
tell btMenu to click
return "断开连接中..."
else
set btCheckboxValue to 1
tell btCheckbox to click
tell btMenu to click
return "连接中..."
end if
else
click btMenu
return "没找到设备"
end if
end tell
end tell
end alfred_script
主要参考文章:
Big Sur AirPods Script
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。