海尔7G笔记本电脑,十几年前的一台笔记本,想在家当服务器用。为了省电,我没有安装桌面,用的是纯命令行模式。
通过网上查询各种文章大模型等等方式,最终找到了解决方案。

使用 vbetool(VESA 电源管理)

‌vbetool‌是一个用于控制VESA BIOS Extension(VBE)的工具,主要用于Linux系统中管理显示器的电源状态。通过vbetool,用户可以关闭或开启显示器的电源,从而实现对显示器电源的管理。
  1. 安装 vbetool

    sudo apt update && sudo apt install vbetool
  2. 测试关闭屏幕

    sudo vbetool dpms off

如果屏幕熄灭,按回车键或输入以下命令恢复:

sudo vbetool dpms on
  1. 创建开机自启服务
    新建文件 /etc/systemd/system/screen-off.service
[Unit]
Description=Turn off screen with vbetool
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/vbetool dpms off

[Install]
WantedBy=multi-user.target
注意,这里可能会报错,大概率是 vbetool 的安装路径不对。可以用 whereis vbetool 命令查一下安装路径,然后修改文件里的路径地址。
  1. 启用服务

    sudo systemctl enable screen-off.service
    sudo systemctl start screen-off.service

飘雪的浮云
54 声望2 粉丝