Fix btrestart command for macOS Monterey 12.2.1+

- Replace deprecated kextunload/kextload approach with launchctl
- Kill audio and bluetooth processes before restarting services
- Use launchctl to restart bluetooth and audio services
- Add error handling with 2>/dev/null || true for robustness
- Fixes issue where kext is 'in use or retained' on modern macOS

Resolves #10934
This commit is contained in:
Paul Frederiksen 2025-10-07 16:24:07 -07:00
commit cb932fe914

View file

@ -19,8 +19,17 @@ alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false &
# Bluetooth restart
function btrestart() {
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
# Kill audio and bluetooth processes
pgrep audio | xargs sudo kill 2>/dev/null || true
pgrep bluetooth | xargs sudo kill 2>/dev/null || true
# Restart bluetooth services using launchctl
sudo launchctl list | grep -i blue | awk '{ print $3 }' | xargs sudo launchctl stop 2>/dev/null || true
sudo launchctl list | grep -i blue | awk '{ print $3 }' | xargs sudo launchctl start 2>/dev/null || true
# Restart audio services using launchctl
sudo launchctl list | grep -i audio | awk '{ print $3 }' | xargs sudo launchctl stop 2>/dev/null || true
sudo launchctl list | grep -i audio | awk '{ print $3 }' | xargs sudo launchctl start 2>/dev/null || true
}
function _omz_macos_get_frontmost_app() {