Skip to content

Instantly share code, notes, and snippets.

@dbuezas
Created December 8, 2023 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbuezas/74c18293c22e6e31bfeb332fa826527f to your computer and use it in GitHub Desktop.
Save dbuezas/74c18293c22e6e31bfeb332fa826527f to your computer and use it in GitHub Desktop.
Restart bluetooth dongles
# Get a list of all controllers
controllers=$(bluetoothctl list | awk '{print $2}')
# Loop through each controller and restart it
for controller in $controllers; do
echo "Turning off: $controller"
# Turn off the controller
echo -e "select $controller\npower off" | bluetoothctl
done
sleep 1 # Wait for 1 second to ensure the power on command has taken effect
for controller in $controllers; do
echo "Turning on: $controller"
# Turn on the controller
echo -e "select $controller\npower on" | bluetoothctl
done
echo "All Bluetooth controllers have been restarted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment