You are not logged in.
This is my /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) echo -n mem >/sys/power/state ;;
*) 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
/usr/sbin/pm-suspend
;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
esac
The only thing I added was the /usr/sbin/pm-suspend.
When I run /usr/sbin/pm-suspend from a terminal, the suspend works fine, but when I try to use the close lid suspend I have trouble resuming. When I open the lid, the laptop starts making noises and lights up (as if it were to resume), but after a while it goes and suspends again.
Pushing the power button to try to resume (this is how I successfully resumed from the commandline suspend) causes the same behavior to happen, so I ended up just holding down the power button and rebooting.
I tried commenting the /usr/sbin/pm-suspend, and uncommented the default echo line. This caused "LID switched!" to be displayed 3 times on /dev/tty5; each one on the next line further to the right. I'm not sure if that is supposed to be normal behaviour.
Offline
The lid button is toggled both when the lid is opened and when the lid is closed. You need to add a check to see whether the lid is opened or closed, or use a more detailed case in your handler script.
M*cr*s*ft: Who needs quality when you have marketing?
Offline
the problem -in my opinion- is caused by laptop-mode-tools. Are you using it?, because I saw a line refering to it on your code.
They say that if you play a Win cd backward you hear satanic messages. That's nothing! 'cause if you play it forwards, it installs windows.
Offline
Hi, I get two LID events. My section for suspending on lid close looks like this:
if grep -q closed /proc/acpi/button/lid/LID0/state
then
logger "ACPI lid closed"
/usr/sbin/pm-suspend
else
logger "ACPI lid opened"
echo -n 2 > /proc/acpi/video/EGFX/LCD0/brightness
fi
When I open the lid, I reset the brightness to 2.
HTH,
Michael
Last edited by mihi (2009-02-05 07:37:41)
Offline
@mihi
While that looks good, I'm not too sure where to put it.
I tried replacing these lines:
button/lid)
#echo "LID switched!">/dev/tty5
/usr/sbin/pm-suspend
But then vim starts making things hilited in red, which scares me.
So then I tried replacing the whole /etc/acpi/handler.sh (I kept the set line and above, but removed everything else), and when I did that, nothing happened.
@kjon
I have laptop-mode-tools now. (But it is set off while on AC power and I did the tests with AC power.) However I first attempted this before I got laptop-mode-tools. I don't think it makes a difference. That is just my default config file.
Offline
Hi, sorry my fault. I should have been more specific. Here my full 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"
/usr/sbin/pm-suspend ;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/sleep)
case "$2" in
SLPB) logger "SleepButton pressed: $2"
/usr/sbin/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
logger "ACPI lid switched $1 $2"
if grep -q closed /proc/acpi/button/lid/LID0/state
then
logger "ACPI lid closed"
/usr/sbin/pm-suspend
else
logger "ACPI lid opened"
echo -n 2 > /proc/acpi/video/EGFX/LCD0/brightness
fi
;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
esac
HTH.
Offline
Oh, I found out the actual problem. I had no /proc/acpi/button/lid/LID0/state, mine was just LID/state. Either way, I got it working now... kinda...
When I open the lid, the computer starts making noises and lighting up as if it were to resume, but then goes into standby again. Only now, if I tap the powerbutton it can sucessfully resume.
I also noticed that brightness doesn't save, it comes back with max brightness. I noticed you changed the brightness there, but the thing is, I don't always use the same brightness, so I wouldn't want to put a default brightness. It isn't so much of a problem because I could always just lower the brightness again though.
Last edited by sokuban (2009-02-05 12:33:09)
Offline
Thank you, sokuban! The tip about having a /LID/state rather than a /LID0/state tipped me off. not is suspends and resumes properly.
Now all I need to do is arrange it so it only does this on battery, and just blanks the screen through xscreensaver when on AC and I would be totally happy. Till I figure that out, suspending with every lid close is a good substitute.
(P.S. laptop-mode-tools has not made it any easier to differentiate suspend/lid closed on batter from suspend/lid closed AC... perhaps there is a way to script this in the handler.sh, but I am not skilled enough at scripting yet to cobble the command together. I am not sure if I can nest lid states within the AC and battery state areas.)
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Well, you could check /proc/acpi/ac_adapter/AC/state. Simple one-line file that contains the status of the AC adapter in your system. Now, how to code that, well, you're on your own. I couldn't code my way out of a wet paper bag!
There may also be a better option in /sys, but I'm a bit lazy to look for it
'One is not born, but becomes a woman. No biological, psychological, or economic fate determines the figure that the human female presents in society.' -Simone de Beauvoir
Offline