]> git.pld-linux.org Git - packages/acpid.git/commitdiff
- reverted 1.6 change
authorhavner <havner@pld-linux.org>
Wed, 27 Sep 2006 00:29:58 +0000 (00:29 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
  - commit log totally irrelevant to commit changes
  - first chunk of patch totally wrong, $2 was there for a reason
  - place for such "state" files is in /var
  - if AC is not a proper dir for your ac connector then make this file
    generic (not for your machine) by commenting relevant log messages
    and making note that this path needs to be configured for user's
    machine

Changed files:
    acpid.battery.sh -> 1.8

acpid.battery.sh

index b8101b289fa8aa0302fdf21ed9bed4c367470529..26c2cc6cd881cd3caf3d9a7321e87bd9801c6441 100644 (file)
@@ -10,18 +10,16 @@ if [ $# != 1 ]; then
 fi
 set $*
 
-AC=/proc/acpi/ac_adapter/ADP1
-BAT=/proc/acpi/battery/BAT1
-STATE_FILE=/tmp/ac_bat_acpid.state
+AC=/proc/acpi/ac_adapter/AC
+BAT=/proc/acpi/battery/$2
 
 # get the AC connector state (plugged/unplugged) from /proc filesystem.
 AC_STATE=`sed -n 's/^.*\(off\|on\)-line.*/\1/p' $AC/state`
-AC_STATE_OLD=`cat "$STATE_FILE" | awk '{print $1};'`
+
 # get the battery state from /proc filesystem
 BAT_CAPACITY=`awk '/^remaining\ capacity:/ {print $3}' $BAT/state`
 BAT_WARNING=`awk '/^alarm:/ {print $2}' $BAT/alarm`
 BAT_CRITICAL=`awk '/^design\ capacity\ low:/ {print $4}' $BAT/info`
-BAT_STATE_OLD=`cat "$STATE_FILE" | awk '{print $2};'`
 if [ "$BAT_CAPACITY" -le "$((BAT_CRITICAL+200))" -a "$AC_STATE" = "off" ]; then
        BAT_STATE=critical
 elif [ "$BAT_CAPACITY" -le "$((BAT_WARNING+200))" -a "$AC_STATE" = "off" ]; then
@@ -29,13 +27,11 @@ elif [ "$BAT_CAPACITY" -le "$((BAT_WARNING+200))" -a "$AC_STATE" = "off" ]; then
 else
        BAT_STATE=normal
 fi
-echo "$AC_STATE $BAT_STATE" >  "$STATE_FILE"
 
-if [ "$AC_STATE" != "$AC_STATE_OLD" ]; then
- case "$AC_STATE" in
+case "$AC_STATE" in
   on)
        # AC connector plugged in
-       logger "acpid: `basename $AC` connector plugged in. State: $AC_STATE."
+       logger "acpid: `basename $AC` connector plugged in."
        # deactivate standby (spindown) timeout for the drive
        #hdparm -q -S 0 /dev/hda
        # handle processor - this feature is deprecated for Kernel > 2.6.11.
@@ -44,26 +40,24 @@ if [ "$AC_STATE" != "$AC_STATE_OLD" ]; then
        ;;
   off)
        # AC connector unplugged
-       logger "acpid: `basename $AC` connector unplugged. State: $AC_STATE."
+       logger "acpid: `basename $AC` connector unplugged."
        # activate standby (spindown) timeout for the drive
        # timeout 5 minutes (man hdparm, for more informations)
-       #hdparm -q -S 60 /dev/sda 
+       #hdparm -q -S 60 /dev/hda 
        # handle processor - this feature is deprecated for Kernel > 2.6.11.
        #echo 4 > /proc/acpi/processor/CPU0/throttling
        #echo 3 > /proc/acpi/processor/CPU0/performance
        ;;
   *)
        # AC connector in undetermined state
-       logger "acpid: Could not determine new `basename $AC` connector state: $AC_STATE."
+       logger "acpid: Could not determine new `basename $AC` connector state."
        ;;
- esac
-fi
+esac
 
-if [ "$BAT_STATE" != "$BAT_STATE_OLD" ]; then
- case "$BAT_STATE" in
+case "$BAT_STATE" in
   warning)
        # battery passed acpi alarm state and AC unplugged
-       logger "acpid: Remaining `basename $BAT` battery capacity low. State: $BAT_STATE."
+       logger "acpid: Remaining `basename $BAT` battery capacity low."
        # play alarm sound
        #play /path_to/alarm.wav
        # put computer to sleep
@@ -72,7 +66,7 @@ if [ "$BAT_STATE" != "$BAT_STATE_OLD" ]; then
        ;;
   critical)
        # some laptops generate acpi event when machine is about to turn off
-       logger "acpid: Remaining `basename $BAT` battery capacity VERY low. State: $BAT_STATE."
+       logger "acpid: Remaining `basename $BAT` battery capacity VERY low."
        # play alarm sound
        #play /path_to/alarm.wav
        # put computer to sleep
@@ -84,7 +78,6 @@ if [ "$BAT_STATE" != "$BAT_STATE_OLD" ]; then
        ;;
   *)
        # battery in undetermined state
-       logger "acpid: Could not determine `basename $BAT` battery state: $BAT_STATE."
+       logger "acpid: Could not determine `basename $BAT` battery state."
        ;;
- esac
-fi
+esac
This page took 0.091291 seconds and 4 git commands to generate.