3 # /etc/acpid/battery.sh
5 # written by Frank Dietrich <ablesoft@gmx.de>
7 # based on default.sh in the acpid package
9 # Detect AC connector plugged in or unplugged and take appropriated actions.
11 # On my notebook no event triggered if AC connector plugged in or unplugged.
12 # So I will use the battery event to detect new powerstate.
14 # get the AC connector state from /proc filesystem.
15 STATE=`sed -n 's/^.*\(off\|on\)-line.*/\1/p' /proc/acpi/ac_adapter/ACAD/state`
19 # AC connector plugged in
20 # make an entry in /var/log/daemon.log
21 logger "acpid: AC connector plugged in."
22 # deactivate standby (spindown) timeout for the drive
23 /sbin/hdparm -q -S 0 /dev/hda
26 # AC connector unplugged
27 logger "acpid: AC connector unplugged."
28 # activate standby (spindown) timeout for the drive
29 # timeout 5 minutes (man hdparm, for more informations)
30 /sbin/hdparm -q -S 60 /dev/hda
33 # AC connector in undetermined state
34 logger "acpid: Could not determine new AC connector state."