|
Size: 3989
Comment: typo
|
Size: 3926
Comment: Mostly changing {{{blah}}} to `blah` to improve source readability.
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 4: | Line 4: |
| In order to trigger suspend on closing the lid, make sure that there is a line in {{{/etc/systemd/logind.conf}}} that reads {{{HandleLidSwitch=suspend}}}, and that it is not commented out (Prefixed with {{{#}}}). By default values are : * HandleLidSwitch=suspend * HandleLidSwitchDocked=ignore Example logind.conf: |
In order to trigger suspend on closing the lid, make sure that there is a line in `/etc/systemd/logind.conf` that reads `HandleLidSwitch=suspend`, and that it is not commented out (prefixed with `#`). The default values are : * `HandleLidSwitch=suspend` * `HandleLidSwitchDocked=ignore` Example `logind.conf`: |
| Line 18: | Line 20: |
| After making the change to {{{logind.conf}}}, run {{{systemctl restart systemd-logind.service}}}. After doing so, you should be able to close the lid of your laptop, and have the laptop suspend. | After making the change to `logind.conf`, run `systemctl restart systemd-logind.service`. After doing so closing the laptop's lid should cause the laptop to suspend.. |
| Line 20: | Line 22: |
| If you are running a simple xsession, and want to make sure your screen locks on suspend, you can install the {{{xscreensaver}}} and {{{xss-lock}}} packages, and add the lines: | If you are running a simple xsession, and want to make sure your screen locks on suspend, you can install the `xscreensaver` and `xss-lock` packages, and add the lines: |
| Line 27: | Line 29: |
| to your {{{.xsession}}}-file | to your `.xsession`-file |
| Line 30: | Line 32: |
| When the laptop suspends to ram, it uses very little power, but the current session is not persisted to disk, so if the battery runs out, the system will be forced to do a full boot on resume. There are two ways around this: the classical way is hybrid-sleep: when suspending the machine also writes current state to disk, as with hibernate -- so if power runs out no data is lost, and the session can be resumed. | When the laptop suspends to ram, it uses very little power, but the current session is not persisted to disk, so if the battery runs out, the system will be forced to do a full boot on resume. There are two ways around this: the classical way is hybrid-sleep: when suspending the machine also writes current state to disk, as with hibernate — so if power runs out no data is lost, and the session can be resumed. |
| Line 32: | Line 34: |
| Unfortunately hibernate, even with an solid-state drive, takes longer than entering suspend -- and this can be inconvenient at times. | Unfortunately hibernate, even with an solid-state drive, takes longer than entering suspend — and this can be inconvenient at times. |
| Line 34: | Line 36: |
| We can use the real-time wake timer to allow the system to wake up from sleep and go straight back to hibernation -- if the system has been suspended for a given amount of time. With systemd, we can do this via a service unit; create the file {{{/etc/systemd/system/suspend-sedation.service}}} consisting of the following: | We can use the real-time wake timer to allow the system to wake up from sleep and go straight back to hibernation — if the system has been suspended for a given amount of time. With systemd, we can do this via a service unit; create the file `/etc/systemd/system/suspend-sedation.service` consisting of the following: |
| Line 68: | Line 70: |
| After creating this file, enable it: {{{sudo systemctl enable suspend-sedation}}}. Now you should be able to enter suspend-mode, either by closing the lid, or via {{{systemctl suspend}}}, and have the system suspend immediately, and be ready to wake up quickly for 5 minutes (300 seconds). After that time, the system should briefly wake up on its own, and immediately hibernate. | After creating this file, enable it: `sudo systemctl enable suspend-sedation`. Now you should be able to enter suspend-mode, either by closing the lid, or via `systemctl suspend`, and have the system suspend immediately, and be ready to wake up quickly for 5 minutes (300 seconds). After that time, the system should briefly wake up on its own, and immediately hibernate. |
| Line 70: | Line 72: |
| In order to see the messages logged by this unit, either use {{{journalctl -u suspend-sedation}}}, or look in /var/log/daemon.log for lines containing "suspend-sedtation". | In order to see the messages logged by this unit, either use `journalctl -u suspend-sedation`, or look in `/var/log/daemon.log` for lines containing "suspend-sedtation". |
| Line 72: | Line 74: |
| This solution is inspired by: https://bbs.archlinux.org/viewtopic.php?pid=1256340, but uses the {{{rtcwake}}} command from the {{{util-linux}}} package (an essential package, it should be installed on all Debian systems by default). The {{{--auto}}} flag adjusts for the situation where the real-time clock might *not* be set to UTC -- this is commonly the case on systems that dual-boot Microsoft Windows, for example. | This solution is inspired by: https://bbs.archlinux.org/viewtopic.php?pid=1256340, but uses the `rtcwake` command from the `util-linux` package (an essential package, it should be installed on all Debian systems by default). The `--auto` flag adjusts for the situation where the real-time clock might *not* be set to UTC — this is commonly the case on systems that dual-boot Microsoft Windows, for example. |
To have a laptop first Suspend to RAM, then after a time save state to disk and power off completely, the following changes can be made to a Debian Jessie system.
Suspend on lid close
In order to trigger suspend on closing the lid, make sure that there is a line in /etc/systemd/logind.conf that reads HandleLidSwitch=suspend, and that it is not commented out (prefixed with #).
The default values are :
HandleLidSwitch=suspend
HandleLidSwitchDocked=ignore
Example logind.conf:
# /etc/systemd/logind.conf [Login] HandleLidSwitch=suspend HandleLidSwitchDocked=suspend # All default lines with comments removed for clarity.
After making the change to logind.conf, run systemctl restart systemd-logind.service. After doing so closing the laptop's lid should cause the laptop to suspend..
If you are running a simple xsession, and want to make sure your screen locks on suspend, you can install the xscreensaver and xss-lock packages, and add the lines:
xscreensaver & xss-lock -- xscreensaver-command --lock &
to your .xsession-file
From Suspend to Hibernate
When the laptop suspends to ram, it uses very little power, but the current session is not persisted to disk, so if the battery runs out, the system will be forced to do a full boot on resume. There are two ways around this: the classical way is hybrid-sleep: when suspending the machine also writes current state to disk, as with hibernate — so if power runs out no data is lost, and the session can be resumed.
Unfortunately hibernate, even with an solid-state drive, takes longer than entering suspend — and this can be inconvenient at times.
We can use the real-time wake timer to allow the system to wake up from sleep and go straight back to hibernation — if the system has been suspended for a given amount of time. With systemd, we can do this via a service unit; create the file /etc/systemd/system/suspend-sedation.service consisting of the following:
# /etc/systemd/system/suspend-sedation.service [Unit] Description=Hibernate after suspend Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279 Documentation=https://wiki.archlinux.org/index.php/Power_management Documentation=https://wiki.debian.org/SystemdSuspendSedation Conflicts=hibernate.target hybrid-suspend.target Before=suspend.target StopWhenUnneeded=true [Service] Type=oneshot RemainAfterExit=yes Environment="ALARM_SEC=300" Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm" ExecStart=/usr/sbin/rtcwake --seconds $ALARM_SEC --auto --mode no ExecStop=/bin/sh -c '\ if [ -z "$(cat $WAKEALARM)" ]; then \ echo "suspend-sedation: Woke up - no alarm set. Hibernating..."; \ systemctl hibernate; \ else \ echo "suspend-sedation: Woke up before alarm - normal wakeup."; \ /usr/sbin/rtcwake --auto --mode disable; \ fi \ ' [Install] WantedBy=sleep.target
After creating this file, enable it: sudo systemctl enable suspend-sedation. Now you should be able to enter suspend-mode, either by closing the lid, or via systemctl suspend, and have the system suspend immediately, and be ready to wake up quickly for 5 minutes (300 seconds). After that time, the system should briefly wake up on its own, and immediately hibernate.
In order to see the messages logged by this unit, either use journalctl -u suspend-sedation, or look in /var/log/daemon.log for lines containing "suspend-sedtation".
This solution is inspired by: https://bbs.archlinux.org/viewtopic.php?pid=1256340, but uses the rtcwake command from the util-linux package (an essential package, it should be installed on all Debian systems by default). The --auto flag adjusts for the situation where the real-time clock might *not* be set to UTC — this is commonly the case on systems that dual-boot Microsoft Windows, for example.
