From cb932fe914e7dd96e750d5ad4a963d67ee23148c Mon Sep 17 00:00:00 2001 From: Paul Frederiksen Date: Tue, 7 Oct 2025 16:24:07 -0700 Subject: [PATCH] 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 --- plugins/macos/macos.plugin.zsh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index 4d73d22c3..df2e0cde7 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -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() {