Created
December 8, 2023 17:52
-
-
Save dbuezas/74c18293c22e6e31bfeb332fa826527f to your computer and use it in GitHub Desktop.
Restart bluetooth dongles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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