The Power Status Changed trigger (v10.0+) executes the macro when your Mac connects or disconnects from a power supply.