DEV Community

drewmullen
drewmullen

Posted on

6 3

Mac: bluetooth reset via terminal

I love my Logitech MX Master mouse because I have it programmed to 3 PCs and I can switch with the simple press of a hardware button. However, sometimes the mouse bluetooth connection to my Mac gets lost and I'm forced to either plug in a new mouse or remove my Mac from its dock (its under my desk) which is a hassle. Thanks to a little research and some good old fashioned unix tools, I have an ez solution! Simply put, this solution will quickly reset your Mac's bluetooth. For me this was enough to grab the mouse again.

Setup:

Install blueutil: brew install blueutil

Map reset command: alias bt_reset="blueutil -p 0 && sleep 1 && blueutil -p 1"

Set that alias wherever you manage your aliases. I have mine set to ~/.alias which is sourced by ~/.zshrc.

Tips:

When you need to run this you may find that your terminal is inaccessible. Here are some keyboard shortcuts to help:

Start a terminal: command + space bar, then type terminal

Restore a minimized terminal: command + tab(hold tab), when you have selected the terminal, press up arrow then space bar. Now your terminal is selected~

Run the reset: just type bt_reset and boom! You've found your mouse

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (1)

Collapse
 
nicklediet profile image
Nicholas Lediet

Thanks so much for this! I recently moved from Ubuntu to a Mac and needed an osx solution for my Bluetooth reset alias I had on Linux.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up