Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Trying to understand how suspend works in 10.10.

http://git.webconverger.org/?p=home.git;a=blob;f=.bashrc;h=8ba57b877e31a03c5f0b1675b42f747d81dd31ad;hb=HEAD#l31

I use an alias suspend='sudo /etc/acpi/sleep.sh && sudo alsactl init 0

The alsactl bit is to re-init my sound card which sometimes does not come out of suspend correctly.

And then:

/etc/acpi/sleep.sh -> /usr/sbin/pm-suspend -> /usr/lib/pm-utils/bin/pm-action -> /usr/lib/pm-utils/pm-functions

Irony is /usr/lib/pm-utils/bin/pm-action claims to be "Simple suspend script".

Still don't know how it works. I think I directly used s2ram before.

share|improve this question
    
I know I'm not explaining much but you could put your alsactl command in its own script in /etc/acpi/resume.d/ and it'll run on-wake. –  Oli Oct 19 '10 at 10:23
add comment

1 Answer

up vote 9 down vote accepted

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:

  1. /etc/pm/config.d is scanned for files that define environment variables.
  2. Each of the scripts in /etc/pm/sleep.d and /usr/lib/pm-utils/sleep.d are called in order with the "suspend" argument.
  3. 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-functions where do_suspend is defined.
  4. The system wakes up.
  5. Each of the scripts in /etc/pm/sleep.d and /usr/lib/pm-utils/sleep.d are 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.

share|improve this answer
    
Thanks kees, though what out of interest, what exactly is the command to trigger the "kernel suspend" in step 3? –  hendry Oct 26 '10 at 9:25
    
I've updated to include that detail too now. –  Kees Cook Oct 26 '10 at 14:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.