trigger power state, triggerpowerstate, kPMTriggerTriggerPowerState — Trigger when the source of power changes.


trigger power state structure { type, now, before, filter };
type : string, choice
now : string, choice, optional
before : string, choice, optional
filter : power source filter structure, optional


Trigger when the source of power changes.

The trigger will fire when a power source's state changes. This change will occur when one of the power source's switches to AC/mains supply, to battery, goes off-line, or is disconnected.

There may be multiple power sources. The trigger can filter which power source's can trigger using the name field as a filter. By providing a previous and now state, the trigger can further filter the power source changes that initiate the trigger.

A trigger without either a before or now state, will trigger whenever the power source state changes. A trigger with one or both the before and now state, will trigger only when those values are matched by the changing power source's state.


type. Type of trigger being described.

type is a string. type must be power state, kPMTriggerType_PowerState.

now. New state of the power source.

now is a string. now is optional. now must be one of the following four constants:

  • off line, kPMTriggerNow_OffLine.
  • ac power, kPMTriggerNow_AcPower.
  • battery, kPMTriggerNow_Battery.
  • unknown, kPMTriggerNow_Unknown.

before. Previous state of the power source.

before is a string. before is optional. before must be one of the following four constants:

  • off line, kPMTriggerBefore_OffLine.
  • ac power, kPMTriggerBefore_AcPower.
  • battery, kPMTriggerBefore_Battery.
  • unknown, kPMTriggerBefore_Unknown.

filter. Power sources to monitor.

filter is a power source filter structure. filter is optional.