You are not logged in.

#1 2011-09-01 02:15:12

Sarai
Member
From: Alaska
Registered: 2010-02-20
Posts: 62

[SOLVED] no suspend on laptop lid close

Hi folks.

I've been reading through the archives and I can tell this is a common problem. However, I couldn't find any solutions that fixed the issue/applied to me. I feel like I'm probably missing something ridiculously obvious in getting this to work. Pretty much everything has gone well this setup, this is the only outstanding issue.

Anyway, my computer is a Pangolin Performance (panp5) from System76. I have acpi and pm-utils installed and acpid is listed as a daemon in /etc/rc.conf.

When I close the lid, the computer does not suspend. Running pm-suspend from a CLI works fine so I assume this is either an issue with acpid not seeing the lid close or not knowing what to do with it. It un-suspends fine when I open the lid after suspending via command line.


Running acpi_listen and closing then reopening the lid:

button/lid LID0 00000080 0000001a
processor CPU0 00000081 000000
processor CPU1 00000081 000000
button/lid LID0 00000080 0000001b
processor CPU0 00000081 000000
processor CPU1 00000081 000000

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
            PBTN|PWRF)  logger "PowerButton pressed: $2" ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                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
       /usr/sbin/pm-suspend 
;;

I've also tried:

button/lid)
    case "$2" in
        LID0) 
	     #echo -n mem >/sys/power/state
            /usr/sbin/pm-suspend
;;

I kind of wonder if this is some sort of permissions issue.  As a normal user, I am in the following groups: lp, wheel, games, network, video, audio, optical, storage, scanner, power, users.

I thoroughly appreciate any and all insight.

[EDIT: minor clarification]

Last edited by Sarai (2011-09-02 04:39:33)

Offline

#2 2011-09-01 03:17:18

measure
Member
Registered: 2009-07-17
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

acpi runs the script with root privileges.  It is in fact independent of your user.

The first thing I notice about your script (which I think might be a copying/pasting error) is that you're missing the `esac` at the end of the script.

Perhaps you could try some debugging by having various parts of the handler.sh script output to a log file to see if they are reached.

For example, try adding

echo LID >> /etc/acpi/acpidebug

inside the button/lid switch.  If this is never written, then something else has gone wrong.

Adding another such command outside of the switch will let you know if script runs at all.

Perhaps, just perhaps, make sure `handler.sh` is executable (another stupid thing that could go wrong; I doubt this is the case).


Thanks,
Ryan

Offline

#3 2011-09-01 05:35:27

Sarai
Member
From: Alaska
Registered: 2010-02-20
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

Hi Ryan- thanks for the super quick response.

I am kind of suspecting handler.sh isn't even getting run. With my script like so:

button/lid)
    case "$2" in
        LID0) 
	#echo -n mem >/sys/power/state
	echo LID >> /etc/acpi/acpidebug	
	/usr/sbin/pm-suspend
	;;
    esac
;;

Nothing is written to acpidebug when I close the lid. Furthermore, I tried this:

    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
			echo NO POWER IN >> /etc/acpi/acpidebug
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
			echo POWER IN >> /etc/acpi/acpidebug
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;

And still nothing is written when I unplug and plug back in my AC adapter.

I did chmod +x /etc/acpi/handler.sh. It didn't give any output, so I'm not sure if it was executable before, but it definitely is now and still no suspend on lid.

Offline

#4 2011-09-01 08:15:21

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: [SOLVED] no suspend on laptop lid close

I had once similar issue. Try to reinstall the acpi and acpid. In my case it worked.


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#5 2011-09-02 00:07:52

Sarai
Member
From: Alaska
Registered: 2010-02-20
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

I tried reinstalling acpi and acpid, still nothing getting written to acpidebug after restoring handler.sh.

I also removed laptop-mode-tools after I read on another thread that it can conflict. No dice. sad

Offline

#6 2011-09-02 00:47:15

measure
Member
Registered: 2009-07-17
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

Again, just to clarify, is your handler.sh well-formed code?  The code in your original post is not a valid bash script:  it's missing an `esac` at the end.

What happens if you run (as root)

# cd /etc/acpi
# ./handler.sh button/lid LID0

Perhaps take out the lines that actually suspend, and just leave the debugging bits; though it doesn't really matter.


Thanks,
Ryan

Offline

#7 2011-09-02 01:11:11

Sarai
Member
From: Alaska
Registered: 2010-02-20
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

I ran that- it spat out:

./handler.sh: line 70: syntax error: unexpected end of file

Something's not getting closed somewhere, as we would say in html. I'm not proficient enough in bash to spot the problem, but here's my 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
            PBTN|PWRF)  logger "PowerButton pressed: $2" ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
			echo NO POWER IN >> /etc/acpi/acpidebug
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
			echo POWER IN >> /etc/acpi/acpidebug
                    ;;
                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)
    case "$2" in
        LID0) 
	#echo -n mem >/sys/power/state
	echo LID >> /etc/acpi/acpidebug	
	/usr/sbin/pm-suspend
	;;
    esac
;;

Offline

#8 2011-09-02 01:43:01

measure
Member
Registered: 2009-07-17
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

Like I keep saying: your code is not a valid script! You're missing an 'esac' at the end of the file!  You're not closing the initial switch.  Change your handler.sh to

#!/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
            PBTN|PWRF)  logger "PowerButton pressed: $2" ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
			echo NO POWER IN >> /etc/acpi/acpidebug
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
			echo POWER IN >> /etc/acpi/acpidebug
                    ;;
                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)
    case "$2" in
        LID0) 
	#echo -n mem >/sys/power/state
	echo LID >> /etc/acpi/acpidebug	
	/usr/sbin/pm-suspend
	;;
    esac
;;
esac

Notice how this one has 'esac' at the very end, differently from your original script.

Offline

#9 2011-09-02 01:55:10

Sarai
Member
From: Alaska
Registered: 2010-02-20
Posts: 62

Re: [SOLVED] no suspend on laptop lid close

Ok, I'll try that. I had actually added an esac at the end already, so I guess I was originally missing two.

[EDIT: thread marked as solved. Thanks, the additional esac solved it- you guys are magical]

Last edited by Sarai (2011-09-02 04:40:35)

Offline

Board footer

Powered by FluxBB