Tizen 2.1 base
[external/acpid.git] / samples / battery / battery.sh
1 #!/bin/sh
2 #
3 # /etc/acpid/battery.sh
4 #
5 #               written by Frank Dietrich <ablesoft@gmx.de>
6 #
7 #               based on default.sh in the acpid package
8
9 # Detect AC connector plugged in or unplugged and take appropriated actions.
10 #
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.
13
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`
16
17 case "$STATE" in
18   on)
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
24     ;;
25   off)
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 
31     ;;
32   *)
33     # AC connector in undetermined state
34     logger "acpid: Could not determine new AC connector state."
35     ;;
36 esac