How to get a big banner when your laptop has come unplugged
I have been using my laptop a lot in situations where the MagSafe connector has become unplugged without my noticing. It's an older Mac so I don't use it on battery power much because it only runs for about two hours. Recently I had to reboot in the middle of a movie so I decided to set up a notification whenever the Mac got unplugged so that I could take care of the problem right away.
Thankfully, KBM has a Power Status Changed trigger, so it was a simple matter to write a macro that uses it. The simplest possible macro would have been to notify me that the power status had changed and leave it to me to figure out which way, but I wanted a little more hand holding. The Power Status Trigger page in the User Manual referred to the BATTERY function, which was what I needed to tell the difference.
The macro is invoked by the Power Status Changed trigger, It checks the
BATTERY() function and if the Mac is on battery power it reports the "Unplugged" status, otherwise it reports the "Plugged In" status. I decided to loop the Unplugged state in case I happened to miss the initial notification. The
While... group will repeat as long as the
BATTERY() function returns
A major enhancement would be to create a way to turn off the notifications for those times that I really do want to be on battery power, and then automatically turn notifications back on after two hours on battery to remind me to get plugged back in. But I'll wait to do that until I need it.
I hope you find this useful. It's my first published KBM macro. Comments and suggestions welcome.
Power Status Changed Macro (v10.0.2)
Power Status Changed.kmmacros (4.2 KB)