New answers tagged laptop
I found the answer. It is to edit the conf. file in /etc/systemd/logind.conf as described in How to disable auto suspend when I close laptop lid?
I have asked a similar question on ask ubuntu and the accepted answer contains (not-ubuntu specific) shell scripts to save / restore window positions. The key point is to use wmctrl to list active windows and xwininfo to query their geometry and later wmctrl again to restore each window's geometry back. wmctrl has to be installed separately.
I suspect you are using systemd. If that is true then use its built-in tool systemctl: systemctl suspend systemctl hibernate systemctl hybrid-sleep systemctl reboot systemctl poweroff systemctl halt As always you can create an alias for any of these commands.
What about pm-utils? Typing pm-suspend at the console suspends on demand. You can install both acpid and acpi-support to sleep your laptop when you close the lid. You have to uncomment LID_SLEEP=true in /etc/default/acpi-support to get the lid working. It did not require policykit-1 for me, but for full disclosure I am on jessie.
Top 50 recent answers are included