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. Consider having such a system lock on lid close until the Linux kernel is updated to support these newer power states.

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 Linux distro such as Ubuntu.

  1. modify /etc/systemd/logind.conf, with uncommented 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. You can always do the manual lock if this doesn’t work when physically docked.