Trigger Macro When Battery Reaches 100%

please i want to :
trigger macro when battery is reach 100%

This shell command:

pmset -g batt | tr "\012|%|'" ' ' | awk '{print $8}'

will print out the current battery percentage. For example, my battery is currently charging and is at 57% so the above command will print out 57.

However, the trick is how to keep it from repeatedly running once the battery is at 100% -- e.g. imagine that you are working all day plugged in and the battery is at 100% all day, I presume you do not want the macro to run all day long.

Also, even when you are plugged in, the battery will sometimes report itself as 99% or 98% even if it hasn't been unplugged. So you'd need to design in some "wiggle room".

The best solution for this is probably Power Manager but I have not been able to get myself to spend $50 for something that only does "one thing" -- well, technically it does more than one thing, but it's all based around one thing -- power level -- and it costs almost 75% more than Keyboard Maestro, which does at least 1,000 things.

Update: I decided to take another look at Power Manger, and I was definitely selling it short before. It can do a lot of different automations, not just power-related. Of course there is a lot of cross-over with what Keyboard Maestro can do (it can run things at specific times, etc) but I felt that I had been a bit unfair towards it. In fact, I've even downloaded the demo and decided to give it a try for 30-days.

1 Like

If you do a search you’ll find many related topics.

I haven’t done an exhaustive search but I remember to have seen a working solution based on the pmset command as @tjluoma has showed you.

And I see no point why it shouldn’t work. Just periodic-trigger your pmset-based macro every 10 minutes or so, and make it trigger your main macro, and you are fine.

An alternative might be iStat Menus by Bjango. It can dish out alerts when your battery is at 100% (or 95%, or whatever). Completely configurable. But it can’t trigger a macro (out of the box).

thank you very much my good friends
OK lets say when the battery is on 98 and it plug to the power
than i just want it to make it to do some sound
than i will unplug it from power
and when the mac warn me with pop up window that the battery is low i will plug it to the power again
until again when the battery reach 98

after i read very carefully your notes i still can not make this macro
please can you add a link to the macro
please

I use this macro for checking power. Originally from Chris
Get Battery Status - Battery or AC Power.kmmacros|attachment
(11.8 KB)

1 Like