Added in 2.3

$batteryp

If running on battery, returns percentage left, otherwise 100.

See also $battery.