折腾一下 PVE 笔记本主机的黑屏、休眠等问题

发布时间 2023-05-03 00:28:18作者: develon

setterm --blank

man手册:

       --blank[=0-60|force|poke]
              Sets  the  interval  of  inactivity,  in  minutes,  after which the screen will be automatically
              blanked (using APM if available).  Without an argument, it gets the blank status (returns  which
              vt was blanked, or zero for an unblanked vt).  Virtual consoles only.

              The force argument keeps the screen blank even if a key is pressed.

              The poke argument unblanks the screen.

什么意思呢?

          设置不活动的时间间隔,以分钟为单位,之后屏幕将自动黑屏(如果可用,使用 APM)。如果没有参数,它会获得黑屏状态。

          force 参数即使按下键也将保持屏幕关闭。

          poke 参数将解除屏幕关闭。

需要注意 0 表示不关闭屏幕,而不是立即关闭。

需要体验一下的话建议使用以下命令:

setterm --blank force; sleep 5; setterm --blank poke

谨慎使用force,因为一旦关闭,基本上只有重启才可以看见屏幕内容了。而用计时器的话可以用按键唤醒屏幕。

笔记本盒盖不休眠

编辑 /etc/systemd/logind.conf 文件:

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff 电源键行为
#HandleSuspendKey=suspend 睡眠
#HandleHibernateKey=hibernate 休眠
#HandleLidSwitch=suspend 盒盖行为
HandleLidSwitch=ignore 直接忽略盒盖行为即可
#HandleLidSwitchExternalPower=suspend 接外部电源时的盖盒行为
HandleLidSwitchExternalPower=ignore 也ignore掉
#HandleLidSwitchDocked=ignore
#HandleRebootKey=reboot

似乎除了ignore,还有lock等操作。
然后重启服务吧:

systemctl restart systemd-logind.service