Make Linux lock on lid close

Some modern hardware (such as Microsoft Surface Book or Surface Pro) with “Connected Standby” or “Modern Standby” is not well supported in Suspend/Sleep with Linux yet.

There are two categories of workaround behavior on lid close:

  1. hibernate
  2. lock

Why lock instead of hibernate on lid close?

I didn’t want to have the laptop constantly hibernating and resuming because this takes too long and causes excessive SSD wear. For better security, I shut my laptop down while in transit. If I’m just going between offices/lab on campus, locking screen with screen turned off gives me sufficient power savings for short walks.

Force Linux lock on lid close

This assumes a systemd-based system such as Ubuntu ≥ 15.04, including Ubuntu 18.04.

  1. modify /etc/systemd/logind.conf, with uncommented line
  2. reboot
  3. verify lock behavior on lid close.


  • Microsoft description of traditional S3 standby vs. connected standby vs. modern standby
  • Lock on lid close may not work when your laptop is physically docked, but does generally work when the laptop is out of dock (as the vast majority of laptop users do). You can always do the manual lock if this doesn’t work when physically docked.



Written by Michael Hirsch, Ph.D. //