The advantage to using s2both is that if the battery runs out while suspended to ram, the system can still resume from disk (after power is restored). The disadvantage is that it's slower, and most of the time the disk image is never used.
This implementation of USuspendMethodAuto takes two integer arguments: The first is a threshold (in terms of battery charge percentage) below which s2disk will be used, on the theory that a laptop with a low battery shouldn't waste any energy on suspending to ram. The second is a threshold above which s2ram only is used, since it's faster and it's less likely that a full battery will run out while suspended. In between, s2both is used as a hedge. hal is used to determine battery percentage. This may need bulletproofing for non-hal systems. Jason --- ususpend.orig 2006-10-11 20:20:39.000000000 -0400 +++ /usr/share/hibernate/scriptlets.d/ususpend 2006-10-11 21:15:19.000000000 -0400 @@ -15,6 +15,31 @@ USUSPEND_PROG=s2disk USUSPEND_RAM_FORCE=0 +GetHalBatteryPercentage() { + local battery charge + battery=`hal-find-by-capability --capability battery` + test "$battery" && \ + charge=`hal-get-property --udi $battery --key battery.charge_level.percentage` + test "$charge" || charge=0 + echo $charge +} + +USuspendChooseMethod() { + local s2both_threshold s2ram_threshold battery_percent + s2both_threshold=$1 + s2ram_threshold=$2 + battery_percent=`GetHalBatteryPercentage` + + if [ $battery_percent -gt $s2ram_threshold ] ; then + USUSPEND_PROG=s2ram + elif [ $battery_percent -gt $s2both_threshold ] ; then + USUSPEND_PROG=s2both + else + USUSPEND_PROG=s2disk + fi + vecho 1 "Using method $USUSPEND_PROG for battery charge $battery_percent." +} + USuspendConfigEnabler() { case "$1" in ususpendmethod) @@ -38,6 +63,10 @@ fi ;; + ususpendmethodauto) + USuspendChooseMethod ${1:-25} ${2:-90} + ;; + ususpendramforce) BoolIsOn "$1" "$2" && USUSPEND_RAM_FORCE=1 || return 0 ;; ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Suspend-devel mailing list Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel