Browse the docs

battery

Returns 1 when the Mac is running on battery power, 0 otherwise.

Keyboard Maestro: BATTERY

Details #

battery() takes no arguments and returns 1 when the Mac is currently powered by its battery, and 0 when it is plugged in. It does not return the charge level.

Parameters #

Takes 0 arguments. {{ battery() }}

Examples #

battery()
→ 0
battery() ? "on battery" : "plugged in"
→ plugged in

Gotchas #

  • A Mac with no battery is on a power source, so it returns 0.

  • Calling it with any argument is an error: battery() takes 0 arguments, got 1.

  • When no real Mac is behind it (tests, previews) or the Mac can't answer, it returns 0.