M README.md => README.md +14 -2
@@ 59,6 59,18 @@ ## Automatically Hibernate When Idle
- I want the tablet to hibernate after a period of inactivity, so I installed and configured [Circadian](https://github.com/mrmekon/circadian).
+ The system should enter a sort of "suspend" state (scare quotes because it's not really actually suspend) which saves some battery, but I wanted the system to hibernate after a longer period of inactivity. Below steps accomplish that:
- In Gnome settings, I set the OS to suspend after 2 minutes of inactivity. As I mentioned above, this does not really suspend -- it blanks the screen and maybe disables wifi. Circadian is set to hibernate after 10 minutes of activity to further save the battery.
+ 1. Add the following line to `/lib/systemd/system/suspend.target`:
+ 1. Copy the `suspend-to-hibernate.service` file in this repo to `/etc/systemd/system/suspend-to-hibernate.service`.
+ 1. Enable the service:
+ sudo systemctl enable suspend-to-hibernate
A suspend-to-hibernate.service => suspend-to-hibernate.service +25 -0
@@ 0,0 1,25 @@
+ Description=delayed hibernation trigger
+ Conflicts=hibernate.target hybrid-suspend.target
+ ExecStart=-/bin/sh -c 'echo -n "alarm set for "; date +%%s -d+10minute | tee $WAKEALARM'
+ ExecStop=-/bin/sh -c '\
+ alarm=$(cat $WAKEALARM); \
+ now=$(date +%%s); \
+ if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then \
+ echo "hibernate triggered"; \
+ systemctl hibernate; \
+ else \
+ echo "normal wakeup"; \
+ fi; \
+ echo 0 > $WAKEALARM; \