Scripting the Battery and Power

Sample AppleScripts for scripting Power Manager's battery and power details.

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

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