CentOS 7 with lid after black screen but not into sleep mode modified
Systemd is able to handle certain power-related ACPI events, which you can configure by following the options from the/etc/systemd/logind.conf:
Handlepowerkey behavior after pressing the Power key
Handlesleepkey behavior after pressing the suspend key
Handlehibernatekey behavior after pressing the Hibernate key
Handlelidswitch behavior after closing the lid of the Notebook
The behavior can be ignore, poweroff, reboot, Halt, suspend, Hibernate, Hybrid-sleep, lock, or kexec.
The system default setting is:
Handlepowerkey=poweroff
Handlesuspendkey=suspend
Handlehibernatekey=hibernate
Handlelidswitch=suspend
Just set the Handlelidswitch option to the following:
Handlelidswitch=lock
Note: The systemctl restart Systemd-logind command does not take effect until the settings have been saved.
Source: http://www.ailab.cn/article/2015082026877.html
From for notes (Wiz)
CentOS 7 with lid after black screen but not into sleep mode modified