CentOS7 电源管理关闭笔记本合盖睡眠待机

Linux可以通过 /etc/systemd 能够定义的电源管理

动作包括: HandlePowerKey:按下电源键后的动作 HandleSleepKey:按下挂起键后的动作 HandleHibernateKey: 按下休眠键后的动作 HandleLidSwitch:合上笔记本盖后待机

这些动作的值可以是 ignore(什么都不做) poweroff(关机) reboot(重新启动) halt(关机,和poweroff有什么区别,需要手动断开电源?) suspend(待机挂起) hibernate(休眠) 默认情况是,当我合上笔记本屏幕的时候,系统会待机。 如果我不想让系统在我合上笔记本的时候待机,怎么办呢?

用vi编辑器打开 /etc/systemd/logind.conf

去掉HandleLidSwitch前面的注释符号#,并把它的值从suspend修改为ignore。

#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
HandleLidSwitch=ignore
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=no
~      

然后systemctl restart systemd-logind,使更改生效。再合上笔记本盖子,也不会待机了。

如果再想进入待机状态,可执行systemctl suspend

Comments