4

Linux学习系列:centos7笔记本合上屏幕不休眠

 1 year ago
source link: https://blog.51cto.com/fengyege/5938964
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux学习系列:centos7笔记本合上屏幕不休眠

精选 原创

最近在折腾 ​​centos7​​​,将其安装在我的老式笔记本,实现资源复用。安装完​​Centos7​​​之后,发现合上屏幕之后,电脑就会进入休眠。本篇博客主要是讲述如何解决这个问题。

Centos

1. 修改配置文件

找到 ​​/etc/systemd/logind.conf​​​,使用​​vim​​命令进入,如:

vim /etc/systemd/logind.conf

搜索 ​​HandleLidSwitch​​,可以看到:

#HandleLidSwitch=suspend

去掉​​#​​​,然后修改为:​​lock​​。结果如下:

HandleLidSwitch=lock

这个配置的可选项为:

ignore 忽略,跳过
power off 关机
eboot 重启
halt 挂起
suspend 可暂停目前正在执行的shell。若要恢复,则必须使用SIGCONT信息。所有的进程都会暂停,但不是消失
hibernate 让笔记本进入休眠状态
hybrid-sleep 混合睡眠,主要是为台式机设计的,是睡眠和休眠的结合体,当你选择Hybird时,系统会像休眠一样把内存里的数据从头到尾复制到硬盘里 ,然后进入睡眠状态,即内存和CPU还是活动的,其他设置不活动,这样你想用电脑时就可以快速恢复到之前的状态了,笔记本一般不用这个功能。
lock 仅锁屏,计算机继续工作

2. 配置生效

systemctl restart systemd-logind

有必要了解的配置:

HandlePowerKey 按下电源键后的行为,默认power off
HandleSleepKey 按下挂起键后的行为,默认suspend
HandleHibernateKey 按下休眠键后的行为,默认hibernate
HandleLidSwitch 合上笔记本盖后的行为,默认suspend

配置生效之后,合上屏幕之后,可以正常访问服务器上面的服务。

PS 随缘求赞、关注

如果我的文章对大家产生了帮忙,可以在文章底部点个赞或者收藏;<br />如果有好的讨论,可以留言;<br />如果想继续查看我以后的文章,可以点击关注<br />也可以扫描以下二维码,关注我的公众号:枫夜之求索阁,查看我最新的分享!<br />

Linux学习系列:centos7笔记本合上屏幕不休眠_合上屏幕
Linux学习系列:centos7笔记本合上屏幕不休眠_合上屏幕_02

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK