如何在Mac上關閉bluetooth
通過terminal
/shell
/automator
/applescript
?它應該很容易。在Mac上關閉藍牙的終端/ shell/automator/applescript命令
順便說一句,我知道你可以得到applescript按bluetooth
菜單,然後按turn bluetooth off
。如果可能的話,我不想要這個。
如何在Mac上關閉bluetooth
通過terminal
/shell
/automator
/applescript
?它應該很容易。在Mac上關閉藍牙的終端/ shell/automator/applescript命令
順便說一句,我知道你可以得到applescript按bluetooth
菜單,然後按turn bluetooth off
。如果可能的話,我不想要這個。
我打算使用blueutil。
- gadgetmo
有兩種方法可以解決這個問題。您可以告知launchd
卸載藍牙守護進程,並不再按需啓動它,或者可以通過編程方式切換它的首選項並停止服務器。
對於前一種方法,使用launchctl
告訴launchd
卸載守護進程,並設置其禁用標誌:
# 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
然後踢的launchd有再次火起來blued
:
# launchctl start com.apple.blued
不知道這個答案是否有效,但是有很多錯誤。首先,它應該是「-bool NO」或「-bool YES」。 「-BOOL」(大寫)和「1」或「0」都是無效參數。 其次,你需要使用sudo:'sudo launchctl start com.apple.blued'。最好使用顯式路徑:'sudo launchctl load/System/Library/LaunchDaemons/com.apple.blued.plist'和'sudo launchctl unload/System/Library/LaunchDaemons/com.apple.blued.plist'。 最後,該pref實際上並沒有設置藍牙是否打開。至少不是獅子。 – 2012-07-22 21:23:33
@SimoneManganelli考慮將您的信息發佈爲一個完整的答案,或者建議對斯賓塞的答案進行編輯。 – 2013-06-03 13:32:37
應該移動到超級用戶,這不是一個編程問題。這就是說,看看[blueutil](http://www.frederikseiffert.de/blueutil/)。它應該做到你想要的。 – 2012-01-02 10:51:02