Hello and welcome to the forums.
When your laptop changes power status (a/c vs battery), scripts in /usr/lib/pm-utils/power.d and /etc/pm/power.d are run. User-created scripts should be added to the /etc/pm/power.d directory as this location won't get over-written during pm-utils updates. The format of the file should be like:
...make sure the file is executable.
case $1 in
true) #battery mode
# "on-battery" commands here
false) #a/c mode
# "on-a/c" commands here
You can review the log file /var/log/pm-powersave.log to see the status of the script as it runs between power changes.