Chapter 9. Scripting the Battery and Power
Example 9.1. Listing Battery and Power Sources
Get the current list of battery and power sources.
tell application "Power Manager" set mySources to every power source in Power end tell
Example 9.2. Checking for a Power Source
Determine if a battery or power source is connected. Power sources include internal and external batteries, and uninterruptible power supplies.
tell application "Power Manager" if every power source in Power is {} then -- There are no batteries or power supplies else -- There is at least one battery or power supply connected end if end tell