Trigger macro When On/Off Battery Power

  1. please i want to trigger macro immediately when mac is charger (the charger cable is insert)

  2. please i want to trigger macro immediately when my mac is out of the charger cable

1 Like

The BATTERY() function can detect whether your Mac is currently charging or not, but it can't be used as a trigger. As far as I can tell, the only way to accomplish something like this (and it is a way I do not recommend) is to have a periodic trigger firing every second and to use an If Then Else condition to check BATTERY() for charging status and proceed accordingly. If you really want to use a macro like this, here's an example for getting started:

Trigger on Charge State.kmmacros (9.1 KB)

This is something that really requires a trigger, not an infinite loop test. Can one of the forum moderators add the "feature_request" tag to this post?

A #feature_request tag does not really do anything. A Battery / Power State change trigger is already on the todo list.

Thanks for your feedback.

Well, I guess that depends on the user. :wink:
Maybe you have chosen not to make good use of this tag, but others of us have.

So, to be clear, the tag DOES do something in the forum. It allows anyone to find all topics with that tag:

Well, yes, to be clear, since I am the only one who implements features, and I don't make use of this tag for any purpose, tagging it is not likely to cause what @dltj desired, which is to have it added to the todo list for Keyboard Maestro.

Ah! Thank you for the context. Yes, coming into the community fresh I thought that post tag was useful. Glad to know it is on the "official" to-do list.

Looks like this has been implemented (correct me if I'm wrong)

If you can see the trigger and have a laptop then you can test it yourself – yes?