On Sun, Nov 05, 2006 at 06:18:34PM +0100, Pavel Machek wrote: > Okay, why not. If you resend the patch, and noone dislikes it, I can > apply it..
Here it is again. Just to be clear, the patch is for Bernard's hibernate scripts; I just CC'd suspend-devel because it may be of general interest to ususpend users. But if you're committing to hibernate svn as well, by all means go ahead. Integrating this into ususpend itself is an interesting idea. It probably wouldn't be especially hard. I wonder what sort of interface hal has for C programs. Jason --- 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. --- hibernate-script/scriptlets.d/.svn/text-base/ususpend.svn-base 2006-11-05 15:38:03.000000000 -0500 +++ hibernate-script/scriptlets.d/ususpend 2006-11-05 15:40:54.000000000 -0500 @@ -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 0 "Using method $USUSPEND_PROG for battery charge $battery_percent." +} + USuspendConfigEnabler() { case "$1" in ususpendmethod) @@ -38,6 +63,10 @@ fi ;; + ususpendmethodauto) + USuspendChooseMethod ${2:-25} ${3:-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