You are not logged in.

#1 2009-11-07 03:23:18

gogi-goji
Member
From: Canada
Registered: 2009-10-20
Posts: 73
Website

hibernate twice when lid closed (acpi) [SOLVED]

I'm trying to get my netbook (A Samsung NC10) to hibernate with pm-hibernate when the lid closes.  With this in /etc/acpi/events/handler.sh, sleep works perfectly, but when I hibernate, it hibernates fine, but when I bring it back up, after about 5 seconds it hibernates again.  Upon bringing it back up the second time, everything works beautifully.  I want to fix it so that my computer only hibernates once when I close the lid.

/etc/acpi/handler.sh

#!/bin/sh
# Default acpi script that takes an entry for all actions

# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

set $*

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PWRF)   logger "PowerButton pressed: $2" ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   pm-suspend ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)    
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        #echo "LID switched!">/dev/tty5
        sudo pm-hibernate
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

Last edited by gogi-goji (2009-11-07 03:51:47)


My (sporadically updated) blog
My miscellaneous dotfiles

Offline

#2 2009-11-07 03:54:03

gogi-goji
Member
From: Canada
Registered: 2009-10-20
Posts: 73
Website

Re: hibernate twice when lid closed (acpi) [SOLVED]

I feel like a retard now.  Countless hours looking for the solution, then I post, and find my own solution accidentally while looking for something else.

fwojciec wrote:

Using something like this in handler.sh seems to take care of the need to resume multiple times after suspend:

    button/lid)
        if [[ `cat /proc/acpi/button/lid/LID0/state | awk '{print $2}'` = "closed" ]]
        then
            pm-suspend
        fi
        #echo "LID switched!">/dev/tty5
        ;;

Diff to the original handler.sh here -- I also created some additional empty events to prevent acpid from logging unnecessary warning messages.  This setup does hibernate when Fn-Esc is pressed and suspend when the lid is closed.

If someone can confirm that this works for them as well maybe we can add it to the wiki...

I'm really impressed with this little machine, btw smile


My (sporadically updated) blog
My miscellaneous dotfiles

Offline

#3 2009-11-20 00:57:54

pecenac
Member
Registered: 2009-09-27
Posts: 14

Re: hibernate twice when lid closed (acpi) [SOLVED]

Unfortunately for me this script doesnt work. When I close the lid on my dell d630 nothing happens. Im running slim with xfce:(

Offline

#4 2009-11-20 01:36:50

gogi-goji
Member
From: Canada
Registered: 2009-10-20
Posts: 73
Website

Re: hibernate twice when lid closed (acpi) [SOLVED]

I don't know if this will help you, but on my Samsung NC10, it takes a few seconds of being closed before it registers as "closed".  Try running

acpi_listen

make sure that your other acpi events are detected, and then close your lid for, like, 15 seconds and see if that is detected as an event.


My (sporadically updated) blog
My miscellaneous dotfiles

Offline

Board footer

Powered by FluxBB