Trigger when Connected to Power

Hi, is there a way to execute a trigger when my MacBook is connected to / disconnected from power?