Skip to content

Instantly share code, notes, and snippets.

@pierot
Last active December 13, 2020 17:42
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pierot/2762217 to your computer and use it in GitHub Desktop.
Save pierot/2762217 to your computer and use it in GitHub Desktop.
Bluetooth for VirtualBox.scpt
--Bluetooth for VirtualBox
--delay 5
set question to display dialog "Manage Bluetooth for ... " buttons {"VirtualBox", "Cancel", "Mac OS"} default button "Cancel" cancel button "Cancel" with icon caution with title "Bluetooth" giving up after 30
set answer to button returned of question
if answer is equal to "VirtualBox" then
-- delay 30
try
do shell script "launchctl unload /System/Library/LaunchDaemons/com.apple.blued.plist"
delay 5
end try
try
do shell script "sudo kextunload -b com.apple.driver.BroadcomUSBBluetoothHCIController" with administrator privileges
delay 5
end try
try
do shell script "sudo kextunload -b com.apple.driver.AppleUSBBluetoothHCIController" with administrator privileges
delay 5
end try
try
do shell script "sudo kextunload -b com.apple.iokit.IOBluetoothSerialManager" with administrator privileges
end try
else if answer is equal to "Mac OS" then
-- delay 30
try
do shell script "sudo kextload -b com.apple.iokit.IOBluetoothSerialManager" with administrator privileges
delay 5
end try
try
do shell script "sudo kextload -b com.apple.driver.AppleUSBBluetoothHCIController" with administrator privileges
delay 5
end try
try
do shell script "sudo kextload -b com.apple.driver.BroadcomUSBBluetoothHCIController" with administrator privileges
delay 5
end try
try
do shell script "launchctl load /System/Library/LaunchDaemons/com.apple.blued.plist"
end try
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment