2

如何在 Mac 上bluetooth通过terminal/ shell/ automator/关闭?applescript这应该很容易。

顺便说一句,我知道你可以让 applescript 按bluetooth菜单然后按turn bluetooth off。如果可能的话,我不想要这个。

4

2 回答 2

3

我将使用blueutil

-- 小工具mo

于 2012-01-03T16:06:55.653 回答
1

有两种方法可以解决。您可以告诉launchd卸载蓝牙守护程序并且不再按需启动它,或者您可以以编程方式切换它的首选项并停止服务器。

对于前一种方法,使用launchctlto telllaunchd卸载守护程序并设置其禁用标志:

# launchctl unload -w /System/Library/LaunchDaemons/com.apple.blued.plist

如果您想稍后恢复它,这应该足够了:

# launchctl load -wF /System/Library/LaunchDaemons/com.apple.blued.plist

那应该这样做。现在对于后一种方法,首先更新首选项文件(从 UI 切换时会发生同样的事情):

# defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState -BOOL 0

然后,您可以粗鲁地关闭服务器:

# killall blued

稍后,您可以通过重置该位来恢复首选项:

# defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState -BOOL 1

然后 kick launchd 让它blued再次启动:

# launchctl start com.apple.blued
于 2012-01-03T06:41:47.350 回答