Configure linux laptop to switch off screen but otherwise remain running when lid closed

I'm not sure how you missed it in the docs, because when I looked it was plainly there.

Place this in logind.conf:

HandleLidSwitch=ignore

According to the documentation at this url, the HandleLidSwitch can be set to lock which locks your session and normally causes the screen to turn off either immediately of a few seconds later. This works well on my Ubuntu-Gnome 17.10. The only downside is you'll have to input your password again when you reopen the lid.

Just add the following line in your /etc/systemd/logind.conf

HandleLidSwitch=lock

Note that there is also a HandleLidSwitchExternalPower if you want different behavior when plugged.

The full set of possible values for HandleLidSwitch and HandleLidSwitchExternalPower is:ignore, poweroff, reboot, halt, kexec, suspend, hibernate, hybrid-sleep, suspend-then-hibernate, and lock


Several people have commented that they can stop their laptop from suspending when closed, but the screen stays on. Maybe this is due to differences in firmware? There is an alternative feature that might work.

At one point, the Linux kernel text console had a default setting that blanked itself after a period of inactivity. An equivalent to the screensaver in your favourite graphical environment :).

Some people like to set the blank time using the kernel boot option consoleblank=, which takes a value in seconds. However, the console blanking feature does not ask the display to enter any power-saving mode.

Remember the original function of a screensaver, was to avoid burning-in a permanent ghost image on your CRT display. It does not necessarily save power. When full power saving was introduced, it was used after a longer delay. Bringing the display back up and running could take a few seconds, which would be much more annoying to the user.


http://man7.org/linux/man-pages/man1/setterm.1.html

Apparently it is possible to enable console blanking at runtime, using setterm --consoleblank [1-60]. And then setterm has another option --powerdown [1-60], to eventually enable "powerdown mode" after a timeout.

If I'm reading it correctly, there's a sequence. First the console blank timeout applies. Then after one powerdown timeout, it applies "vsync suspend mode". Finally after a second powerdown timeout, it applies "powerdown mode". These timeouts are all specified in minutes, not seconds.

So I think you can use a command like this:

 /bin/setterm -term linux -blank 10 -powerdown 5 </dev/tty1 >/dev/tty1

I'm not sure whether CoreOS lets you add arbitrary commands to the boot process (as in rc.local on other distributions, for example). I imagine you can always use a privileged container :).


setterm --blank says that blanking uses APM if available. Narrator voice: APM is not available on modern hardware. I don't know if blanking will use any modern power saving scheme.

"powerdown" mentions "VESA" display power saving. "VESA" power saving is still a thing. I don't know if "powerdown" is necessary or even sufficient to work for modern stuff.

setterm does not say what the default "powerdown" settings are. It looks like "powerdown" is not enabled by default.