Bluetooth connection maintainer This script will keep a bluetooth connection alive by checking if the device is connected every X minutes and if not, it will try to connect to it.
I have a bluetooth speaker that I use with my mac. I noticed that when my mac goes to sleep, the bluetooth connection is lost and I have to reconnect to the speaker every time I wake up my mac. This script will keep the connection alive.
- Install blueutil with
brew install blueutil
- Install jq with
brew install jq
- Clone this repo
git clone https://github.com/MendyLanda/mac-blue-keep-alive.git
- cd into the repo folder
cd mac-blue-keep-alive
- Pair your bluetooth device with your mac
- Modify
run.bash
to include your bluetooth device name and other settings - Run
chmod +x run.bash && ./run.bash
- run
crontab -e
and remove the line that was added by the script - alternatively, you can clear all cron jobs by running
crontab -r
DEVICE_NAME
- the name of the bluetooth device you want to keep aliveCHECK_INTERVAL
- the interval in minutes to check if the device is connected
- To see the logs run:
tail -f /tmp/stdout.log
tail -f /tmp/stderr.log
for errors
- This script is working for me, but I'm not a bash expert. If you have any suggestions, please let me know.
- The script no longer uses Python and the
PYTHON_RUNNER
setting has been removed.