SOURCES: acpid.battery.sh - reverted 1.6 change - commit log tot...

havner havner at pld-linux.org
Wed Sep 27 02:30:03 CEST 2006


Author: havner                       Date: Wed Sep 27 00:30:03 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- reverted 1.6 change
  - 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

---- Files affected:
SOURCES:
   acpid.battery.sh (1.7 -> 1.8) 

---- Diffs:

================================================================
Index: SOURCES/acpid.battery.sh
diff -u SOURCES/acpid.battery.sh:1.7 SOURCES/acpid.battery.sh:1.8
--- SOURCES/acpid.battery.sh:1.7	Wed Sep 27 02:21:47 2006
+++ SOURCES/acpid.battery.sh	Wed Sep 27 02:29:58 2006
@@ -10,18 +10,16 @@
 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 @@
 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 @@
 	;;
   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 @@
 	;;
   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 @@
 	;;
   *)
 	# 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
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/acpid.battery.sh?r1=1.7&r2=1.8&f=u



More information about the pld-cvs-commit mailing list