https://andrewbaker.ninja/wp-content/themes/twentysixteen/fonts/merriweather-plus-montserrat-plus-inconsolata.css

👁6views
How to Automatically Turn your bluetooth off and on when you open and close your MacBook

CloudScale SEO — AI Article Summary
What it isA simple script that automatically turns off Bluetooth when you close your MacBook lid and turns it back on when you open it.
Why it mattersThis prevents Bluetooth devices like headphones from connecting to your closed MacBook, avoiding frustrating interruptions when you're trying to use those devices with other equipment.
Key takeawayYou can eliminate the annoyance of Bluetooth devices connecting to your sleeping MacBook with one simple automation script.

If you’re like me, little things bother you. When I turn on my bluetooth headset and it connects to my Macbook when its closed/sleeping, I get very frustrated. So I wrote a simple script to fix this behaviour. After running the script below, when you close the lid on your Macbook it will automatically turn bluetooth off. When you open you Macbook it will automatically re-enable bluetooth. Simple 🤓

If you need to install brew/homebrew on your mac then run this:

## Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
## IMPORTANT: Once the install finishes run the two commands displayed in the terminal window
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Script to automatically enable/disable bluetooth:

## Install the bluetooth util and sleepwatcher
brew install sleepwatcher blueutil
## This creates a file which switches bluetooth off when the macbook lid is closed
echo "$(which blueutil) -p 0" > ~/.sleep
## This creates a file which switches on bluetooth when the lid is open
echo "$(which blueutil) -p 1" > ~/.wakeup
## This makes both the files runable
chmod 755 ~/.sleep ~/.wakeup
## Finally restart the sleepwatcher service (to pickup the new files)
brew services restart sleepwatcher

4 thoughts on “
👁6views
How to Automatically Turn your bluetooth off and on when you open and close your MacBook”

  1. Error comment:

    blueutil: A full installation of Xcode.app is required to compile
    this software. Installing just the Command Line Tools is not sufficient

    This script seems to work only if you have the full version of Xcode installed (Apple general IDE).

Leave a Reply

Your email address will not be published. Required fields are marked *