On Fri, 2009-11-20 at 22:21 +0100, Christian Krause wrote: > Hi, > > Ever since I've started to use my netbook under Linux I've missed > quite much the feature of "auto-hibernate" which was available in windows: > > In order to save as much battery power as possible Windows did the > following: > > - after some minutes of inactivity (or closing the LID) the netbook > was suspended (to RAM) > > - if the user has woken it up during the next 15 minutes, it just > resumed quickly > > - otherwise it woke up automatically only to fully hibernate now > > By using this process the user didn't had to think about what would > be the best option to save power or what he must do to prevent that the > suspend mode would drain the battery, everything was done completely > automatically. Especially for only occasional usage of the netbook/laptop > it was very handy and so the time until the next recharge was quite long. > > Using hybrid-suspend was not an option, because even if it would enable > the user to resume after a complete power-loss it does not prevent draining > the battery... > > > I've missed that feature so much, that Ingo van Lil and I have put together > an extension to pm-utils which implements this feature. > > It is implemented by only one additional file in /usr/lib/pm-utils/sleep.d/ > and a configuration file in /etc). Both files are attached to this mail. > > > What's your opinion about this idea? > Is there a chance to integrate this into the official pm-utils? > If yes, we would certainly help to achieve this! ;-)
Seems like it would be better to expose this functionality as a sleep method, not a hook -- no sense in resuming from suspend, waking all the way back up, figuring out that we just want to go straight back to hibernate, and then go do that -- the less we do between waking up and hibernating, the less there is to go wrong. > Best regards, > Christian > > /usr/lib/pm-utils/sleep.d/000auto-hibernate: > > #! /bin/sh > # > # Copyright 2009 Ingo van Lil <ing...@gmx.de> > # Christian Krause <c...@plauener.de> > # > # This program is free software; you can redistribute it and/or modify > # it under the terms of version 2 of the GNU General Public License as > # published by the Free Software Foundation. > > . "${PM_FUNCTIONS}" > > # constants > # how long to wait for the main script to release the lock in seconds > LOCK_TIMEOUT=10 > > # defaults > RTC="/sys/class/rtc/rtc0" > TIME_TO_HIBERNATE=900 > > # get user configured values > source /etc/pm-utils-auto-hibernate.conf > > # Is auto-hibernate enabled ? > [ "$AUTO_HIBERNATE_ENABLED" = "y" ] || exit $NA > > schedule_alarm () { > now=`cat "${RTC}/since_epoch"` > alarm_time=$((now + TIME_TO_HIBERNATE)) > savestate auto-hibernate-alarm ${alarm_time} > echo > "${RTC}/wakealarm" > echo ${alarm_time} > "${RTC}/wakealarm" > } > > schedule_hibernate () { > # wait for pm-action to terminate ... > spin_lock "${STASHNAME}.lock" ${LOCK_TIMEOUT} || exit 1 > release_lock "${STASHNAME}.lock" > # ... before hibernating > pm-hibernate > } > > auto_hibernate () { > now=`cat "${RTC}/since_epoch"` > wakealarm=`cat "${RTC}/wakealarm"` > alarm_time=`restorestate auto-hibernate-alarm` > if [ -n "${alarm_time}" ]; then > if [ ${now} -ge ${alarm_time} -a ${now} -lt $((alarm_time + > 30)) ]; then > echo "Woken up by RTC, auto-hibernating ..." > schedule_hibernate & > elif [ "${alarm_time}" = "${wakealarm}" ]; then > # cancel alarm > echo > "${RTC}/wakealarm" > fi > fi > } > > case $1 in > suspend) schedule_alarm ;; > resume) auto_hibernate ;; > help) help ;; > *) exit $NA ;; > esac > > > /etc/pm-utils-auto-hibernate.conf: > > # RTC="/sys/class/rtc/rtc0" > TIME_TO_HIBERNATE=30 > AUTO_HIBERNATE_ENABLED=y > > _______________________________________________ > Pm-utils mailing list > Pm-utils@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/pm-utils _______________________________________________ Pm-utils mailing list Pm-utils@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pm-utils