Created
October 1, 2023 01:05
-
-
Save nlgthuan/267d5340cd137491326fd69ddfc05e69 to your computer and use it in GitHub Desktop.
Script to toggle bluetooth off and on in MacOS using bluutil
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
| #!/bin/bash | |
| # Turn off Bluetooth | |
| echo "π Turning off Bluetooth..." | |
| blueutil --power 0 | |
| if [ $? -eq 0 ]; then | |
| echo "β Bluetooth has been turned off." | |
| else | |
| echo "β Failed to turn off Bluetooth." | |
| exit 1 | |
| fi | |
| # Sleep for 1 second | |
| echo "β± Waiting for 1 second..." | |
| sleep 1 | |
| # Turn Bluetooth back on | |
| echo "π Turning on Bluetooth..." | |
| blueutil --power 1 | |
| if [ $? -eq 0 ]; then | |
| echo "β Bluetooth has been turned back on." | |
| else | |
| echo "β Failed to turn on Bluetooth." | |
| exit 1 | |
| fi | |
| echo "π Script executed successfully." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment