笔记本 合上 盖子 屏幕 防止 Linux 系统 休眠
闲置的笔记本安装 CentOS 没有桌面的那个版本后, 默认情况下合上笔记本盖子会导致电脑进入休眠状态
解决办法
通过修改 /etc/systemd/logind.conf 配置文件解决合上盖子系统进入休眠的状态
logind.conf 文件内容如下
[Login]
#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
其中需要修改的
HandlePowerKey:按下电源键后的动做
HandleSleepKey:按下挂起键后的动做
HandleHibernateKey: 按下休眠键后的动做
HandleLidSwitch:合上笔记本盖后待机
值说明
下面这些值都是 logind.conf 文件中的配置项可以用的值
ignore(什么都不作)
poweroff(关机)
reboot(从新启动)
halt(关机,和poweroff有什么区别,须要手动断开电源?)
suspend(待机挂起)
hibernate(休眠)
修改完后生效的方法
方法一: 重启系统
方法二: 执行 systemctl restart systemd-logind 命令