10.13. Laptop Power (APM)

If you have a laptop with APM installed, try the following PROMPT_COMMAND to create an environment variable ${battery} you can add to your prompt. This will indicate if AC power is connected and percentage power remaining. AC power is indicated by a "^" (for on) and a "v" (for off) before the percentage value.

function prompt_command {
	#  As much of the response of the "apm" command as is 
	#  necessary to identify the given condition:
   NO_AC_MESG="AC off"
   AC_MESG="AC on"

   case ${APMD_RESPONSE} in

   battery="${temp##* }"

This worked the last time I had access to an APM-based system, but I'm afraid that was years gone. If you have an APM system and have to make changes, please let me know.