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. We recommend simply having such a system lock on lid close (or do nothing) until the Linux kernel is updated to support these newer power states. We do not even consider hibernate on lid close because this takes too long and causes excessive SSD wear.

For better security in general, shut the laptop down while in transit in case of loss or theft. If just going between offices/lab on campus, locking screen with screen turned off gives 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 *un*commented line

    HandleLidSwitch=lock
    
  2. reboot

  3. verify lock behavior on lid close.

Notes

  • 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.