Quote:
Originally Posted by narke
Hi,
Below is a piece of copy from my /etc/acpi_handler.sh
...
case "$1" in
button)
case "$2" in
power) /sbin/init 0
/usr/bin/date >> /var/log/battery-log 2>&1
/usr/bin/acpitool -B >> /var/log/battery-log 2>&1
;;
*)
logger "ACPI group $1 / action $2 is not defined"
;;
esac
;;
...
But I never see the /var/log/battery-log exists in my file system and my laptop was running out of battery and got shutdown abnormally.
Is there something wrong in my acpi_handler.sh script?
-
narke
|
---------------------------
An important thing to note is that the way acpi handles events is:
1) event generated ---> passed to kernel --> kernel spews out event to file /etc/acpi/events/default
(contents of /etc/acpi/events/default)
event=.*
action=/etc/acpi/acpi_handler.sh %e
2) note that all events (i.e. event=.*) are sent to /etc/acpi/acpi_handler.sh
3) your script above is for /etc/acpi/acpi_handler.sh is only interested in the button events
the button event is generated when you press the power button on your computer
4) in older kernels the information for battery was stored in the "/proc/acpi/battery/" directory;
for newer kernels the information for battery is stored in "/sys/class/power_supply/" directory
in directory [BAT0] and/or [BAT1] depending how linux detects your batteries and the number of batteries on your systems
5) you can read the battery information from /proc/sys/class/power_supply/BAT0 directory (if you battery is detected as [BAT0])
6)using simple mathematics/arithmetic, you can actually run a shell (bash) script that can shutdown your laptop during low battery situations
when laptop is not being charged by A/C power
7) you can write information to log files (/var/log/messages) about low battery events using the script you develop for turning off your machine
For further reading about using ACPI statistics to turn off a laptop during low battery situations:
Goto (LOL!):
http://www.gen.horizon-host.com/linux.php
click on:
Configuring ACPI - Laptop Battery and Automatic Shutdown
Tix
"Blessed are the angry, for they shall inherit the national debt."
--