如何在Mac上通过 terminal / shell / automator / applescript 关闭 bluetooth ?应该很容易 .
terminal
shell
automator
applescript
bluetooth
顺便说一句,我知道你可以按下 bluetooth 菜单然后按 turn bluetooth off 获取AppleScript . 如果可能,我不想要这个 .
turn bluetooth off
我打算用blueutil .
有两种方法可以解决它 . 您可以告诉 launchd 卸载蓝牙守护程序,不再按需启动它,或者您可以通过编程方式切换它的首选项并停止服务器 .
launchd
对于前一种方法,使用 launchctl 告诉 launchd 卸载守护进程并设置其禁用标志:
launchctl
# 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
然后踢了一下,让它再次启动 blued :
blued
# launchctl start com.apple.blued
2 回答
我打算用blueutil .
有两种方法可以解决它 . 您可以告诉
launchd
卸载蓝牙守护程序,不再按需启动它,或者您可以通过编程方式切换它的首选项并停止服务器 .对于前一种方法,使用
launchctl
告诉launchd
卸载守护进程并设置其禁用标志:如果你想稍后恢复它,这应该足够了:
应该这样做 . 现在对于后一种方法,首先更新首选项文件(从UI切换时会发生同样的事情):
然后,你可以粗暴地杀掉服务器:
稍后,您可以通过重置位来恢复首选项:
然后踢了一下,让它再次启动
blued
: