Created
June 7, 2023 11:57
-
-
Save andmax/d6c02d49415b99d981a6a74d796edc8c to your computer and use it in GitHub Desktop.
Script to restart bluetooth
This file contains hidden or 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
#!/usr/bin/bash | |
echo 'clearing dmesg...'; | |
sudo dmesg -c && clear; | |
DEVICE=$(rfkill list all | grep -o 'hci*.'); | |
sudo hciconfig ${DEVICE} down; | |
sudo rmmod btusb; | |
sudo service bluetooth disable; | |
sudo modprobe btusb; | |
sudo hciconfig ${DEVICE} up; | |
sudo service bluetooth enable; | |
echo '\n~~rfkill:'; | |
rfkill unblock bluetooth; | |
rfkill list all; | |
echo "\n~~~DMESG:"; | |
sudo dmesg | grep -i bluetooth; | |
echo '\n~~~bluetooth status:'; | |
sudo service bluetooth status; | |
echo '\n~~~if failed try manually:'; | |
bluetoothctl power on; | |
bluetoothctl devices; | |
read DEVICE_TO_CONNECT; | |
bluetoothctl connect ${DEVICE_TO_CONNECT} | |
echo "~~~\nFINISH UP:\n~~~~run bluetoothctl;\n~~~~~power on && devices && connect"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment