HOWTO: sound after hibernate in Linux (Gusty/Lenny)

Ignignokt says - Using a key to gouge expletives on another’s vehicle is a sign of trust and friendshipWith all the tweaking to get my Dell Vostro 1500 working with Ubuntu, it’s still been an annoyance to get sound working evertime after hibernation. It goes to sleep fine, it wakes up fine, it obeys all of the power preferences I defined within Gnome fine too, it’s just that when it comes out of hibernation, the sound is usually off. It’s not muted, it’s off. Trying to restart alsa (the sound server) is a lession in frustration, so until now I’ve been ignoring it since it was rare that I would need it, but still…come on. This week I came across a solution in the Debian Forums that creates a new task for Linux to do before it shuts down and before it starts up.: “Create the file /etc/pm/sleep.d/49sound…

mkdir /etc/pm
vi /etc/pm/sleep.d49sound

with the following contents:

function kill_sound_apps() {
pidsnd=$(lsof | grep /dev/snd | awk '{ print $2 }')
pidmixer=$(lsof | grep /dev/mixer | awk '{ print $2 }')
piddsp=$(lsof | grep /dev/dsp | awk '{ print $2 }')
kill $pidsnd $pidmixer $piddsp
}

case "$1" in
hibernate|suspend)
kill_sound_apps
modprobe -r snd_hda_intel
;;
thaw|resume)
modprobe snd_hda_intel
;;
*)
;;
esac

exit $?

Then just make it executable:

# chmod +x /etc/pm/sleep.d/49sound

So before shutting down, Linux properly shuts down the sound, and when it comes back it, it properly starts the sound. As always, this *should* work, but the fact that it hasn’t been updated in Ubuntu Gusty is one of the reasons I’m shifting to Debian Lenny on this ‘top.

NOTE: yes, I am thinking of making Ignignokt my official HOWTO mascot. “Using a key to gouge expletives on another’s vehicle is a sign of trust and friendship

  • JoHn

    root@acer:/home/zsebi # sh /etc/pm/sleep.d/sleep.d49sound
    /etc/pm/sleep.d/sleep.d49sound: 1: Syntax error: “(” unexpected

  • JoHn

    root@acer:/home/zsebi # sh /etc/pm/sleep.d/sleep.d49sound
    /etc/pm/sleep.d/sleep.d49sound: 1: Syntax error: “(” unexpected

  • http://fak3r.com/ fak3r

    @JoHn

    Check the syntax of your file, it _sounds_ like you have an extra (, or are missing the corresponding closing ) Feel free to post the code here if you want me to take a gander.

  • http://fak3r.com fak3r

    @JoHn

    Check the syntax of your file, it _sounds_ like you have an extra (, or are missing the corresponding closing ) Feel free to post the code here if you want me to take a gander.

  • egor08

    Thanks a lot! I have the same problem with my laptop and so far this is the first thing that worked. However, when my computer boots up after the hibernation, I get an error box saying that the “volume control had quit unexpectedly.” It is not really a problem, since it offers to reload it. Still, I was wandering if there is a way to avoid this?

  • egor08

    Thanks a lot! I have the same problem with my laptop and so far this is the first thing that worked. However, when my computer boots up after the hibernation, I get an error box saying that the “volume control had quit unexpectedly.” It is not really a problem, since it offers to reload it. Still, I was wandering if there is a way to avoid this?

  • http://fak3r.com/ fak3r

    @egor08
    Hey, glad it worked as for the “volume control” issue, is that referring to the volume applet on the taskbar? If so I’d think it’d be more of a system issue than anything else. Two things I’d try, do a complete update to make sure you have the latest of everything, and if that fails:

    mv ~/.gnome* ~/.gconf* /tmp

    then logout and back in. You’ll have to reconfigure your desktop the way you had it, but see if that cleans things out.

  • http://fak3r.com fak3r

    @egor08
    Hey, glad it worked as for the “volume control” issue, is that referring to the volume applet on the taskbar? If so I’d think it’d be more of a system issue than anything else. Two things I’d try, do a complete update to make sure you have the latest of everything, and if that fails:

    mv ~/.gnome* ~/.gconf* /tmp

    then logout and back in. You’ll have to reconfigure your desktop the way you had it, but see if that cleans things out.

  • Wiggoggs

    Hey, this script is great. I used this in Mandriva 2008 spring and it worked like a charm. The only problem is that when putting it to sleep while kde is up, it doesn’t restart kmix after waking up. But it is well worth it anyway, nice work!

  • Wiggoggs

    Hey, this script is great. I used this in Mandriva 2008 spring and it worked like a charm. The only problem is that when putting it to sleep while kde is up, it doesn’t restart kmix after waking up. But it is well worth it anyway, nice work!

  • http://fak3r.com/ fak3r

    @Wiggoggs
    Great, glad to hear it was helpful. As for not restarting kmix, how about appending a line at the end of the ‘resume’ stanza like:

    [...]
    modprobe snd_hda_intel
    /etc/init.d/kmix restart

  • http://fak3r.com fak3r

    @Wiggoggs
    Great, glad to hear it was helpful. As for not restarting kmix, how about appending a line at the end of the ‘resume’ stanza like:

    [...]
    modprobe snd_hda_intel
    /etc/init.d/kmix restart

  • Kan

    Hi.
    It also worked in ubuntu 8.10 (intrepid ibex).
    Thank you!!

    I have the same problem than the one reported by egor08, but is not a big deal.
    Kan.

  • Kan

    Hi.
    It also worked in ubuntu 8.10 (intrepid ibex).
    Thank you!!

    I have the same problem than the one reported by egor08, but is not a big deal.
    Kan.

  • http://hehe2.net/ Rami Taibah

    This worked great thanks!

    But one minor problem. Am running xfce on xubuntu. When ever it resumes the interface gets a big ugly, as if am running the apps using root or something… Can provide you a before and after screenshots if I wasn’t clear enough…

  • http://hehe2.net Rami Taibah

    This worked great thanks!

    But one minor problem. Am running xfce on xubuntu. When ever it resumes the interface gets a big ugly, as if am running the apps using root or something… Can provide you a before and after screenshots if I wasn’t clear enough…

  • Jacco

    Could this not work simpler by creating a file in /etc/pm/config.d/ containing:
    SUSPEND_MODULES=”snd-hda-intel”

    It would let pm-utils take care of unloading and loading the module upon hibernate and resume, see man pm-hibernate.

  • Jacco

    Could this not work simpler by creating a file in /etc/pm/config.d/ containing:SUSPEND_MODULES=”snd-hda-intel”It would let pm-utils take care of unloading and loading the module upon hibernate and resume, see man pm-hibernate.

  • Anonymous

    Thanks!!! I have a similar problem in my Laptop but with WIFI
    When i hibernate, on resume the wifi dont work, but if i type:

    sudo ifdown wlan0 && sudo ifup wlan0

    the wifi works again. Then i use your script modify like this:

    case “$1″ in
    hibernate|suspend)
    ifdown wlan0
    ;;
    thaw|resume)
    ifup wlan0
    ;;
    *)
    ;;
    esac

    exit $?

    And it works like a charm!!!
    Sorry my English

    • http://fak3r.com fak3r

      Hey, that’s great to hear, always nice when old solutions are still helping people. Also, your English is just fine, I should be the one apologizing since I never mastered another language, so my hats off to you! Nice Gorillaz avatar too!

  • dario2004

    Thanks!!! I have a similar problem in my Laptop but with WIFIWhen i hibernate, on resume the wifi dont work, but if i type:sudo ifdown wlan0 && sudo ifup wlan0the wifi works again. Then i use your script modify like this:case “$1″ inhibernate|suspend)ifdown wlan0;;thaw|resume)ifup wlan0;;*);;esacexit $?And it works like a charm!!!Sorry my English

  • http://fak3r.com fak3r

    Hey, that's great to hear, always nice when old solutions are still helping people. Also, your English is just fine, I should be the one apologizing since I never mastered another language, so my hats off to you! Nice Gorillaz avatar too!

  • http://fak3r.com fak3r

    Hey, that's great to hear, always nice when old solutions are still helping people. Also, your English is just fine, I should be the one apologizing since I never mastered another language, so my hats off to you! Nice Gorillaz avatar too!

Read previous post:
(Paranoid) Android demo

Here's a working demo of Google's Android operating system in action.  It's got some pretty fly features, with a few [...]

Close