The gnome-power-manager tool listens for suspend button events, and spawns pm-suspend. Extensive detail about how pm-suspend operates can be found in the man pm-suspend command output. The quick version:
- /etc/pm/config.dis scanned for files that define environment variables.
- Each of the scripts in /etc/pm/sleep.dand/usr/lib/pm-utils/sleep.dare called in order with the "suspend" argument.
- The system is put to sleep via the defined interface module. By default, this is the kernel suspend interface: echo -n "mem" >/sys/power/state. See/usr/lib/pm-utils/pm-functionswheredo_suspendis defined.
- The system wakes up.
- Each of the scripts in /etc/pm/sleep.dand/usr/lib/pm-utils/sleep.dare called in reverse order with the "resume" argument.
If you need to add a script to the stack, I would suggest adding it to /etc/pm/sleep.d and name it something that does not conflict with other scripts, and make sure it processes the "suspend"/"resume" argument.
For debugging, see /var/log/pm-suspend.log as well as the man page which has more information on how to do testing.