How to Tell When the Laptop Lid is Closed

There is an astoundingly powerful macOS shell command called "pmset" that tells you a TON of information about your Mac. Try this:

pmset -g ps / batt

Since I don't have a battery, all it tells me is that I'm running on AC power. But for you, it may tell you the battery's power level.

By writing a macro that triggers every minute (or 5 minutes?) I think you could use this to tell if the battery was draining. Generally speaking, power drains only if the device is unplugged, right? Would that help you?

You could put that command into a KM Execute Shell Script command that returns the result into a KM variable which you could test intermittently for changes.

Come to think of it, I'm going to add to my TODO list the creation of a macro that lets the user interface with all the features of the pmset command. Unless someone else does it first.

Okay, here's a preliminary macro that displays the top ~24 items, based on what option you choose.

PMSET Action (v11.0.1)

Group.kmactions (7.3 KB)

Keyboard Maestro Export

Using the pmset command, I could get KM to send me a text message when my trackpad or keyboard's battery level drops below, say 10%.