Make your Ubuntu notebook hibernate after a period of sleep. The Ubuntu forums here go into depth but the script from the very helpful posters is:
#!/bin/bash # Script name: /etc/pm/sleep.d/0000rtchibernate # Purpose: Auto hibernates after a period of sleep # Edit the "autohibernate" variable below to set the number of seconds to sleep. curtime=$(date +%s) autohibernate=7200 echo "$curtime $1" >>/tmp/autohibernate.log if [ "$1" = "suspend" ] then # Suspending. Record current time, and set a wake up timer. echo "$curtime" >/var/run/pm-utils/locks/rtchibernate.lock rtcwake -m no -s $autohibernate fi if [ "$1" = "resume" ] then # Coming out of sleep sustime=$(cat /var/run/pm-utils/locks/rtchibernate.lock) rm /var/run/pm-utils/locks/rtchibernate.lock # Did we wake up due to the rtc timer above? if [ $(($curtime - $sustime)) -ge $autohibernate ] then # Then hibernate rm /var/run/pm-utils/locks/pm-suspend.lock /usr/sbin/pm-hibernate else # Otherwise cancel the rtc timer and wake up normally. rtcwake -m no -s 1 fi fi
Then
- Place in /etc/pm/sleep.d
- Name file 000rtchibernate so that it executes first.
See: askubuntu.com/questions/12383/how-to-automatically-from-suspend-into-hibernate
Leave a comment