Display Power Management Signaling (简体中文)
DPMS (VESA 显示电源管理信号,简称DPMS)是VESA制定的通过显示卡对显示器电源管理的标准。DPMS规定如果一定时间不对计算机进行操作时显示器自动进入节电模式。
Contents
在X中设定DPMS
在 /etc/X11/xorg.conf
的 Monitor
小节写上:
Option "DPMS" "true"
把下面的配置加入 ServerLayout
小节, 必要时改变时间(以分钟计):
Option "StandbyTime" "10" Option "SuspendTime" "20" Option "OffTime" "30"
比较新的X推荐使用 .conf
文件代替 xorg.conf
, /etc/X11/xorg.conf.d/10-monitor.conf
的一个例子如下:
Section "Monitor" Identifier "LVDS0" Option "DPMS" "false" EndSection Section "ServerLayout" Identifier "ServerLayout0" Option "BlankTime" "0" Option "StandbyTime" "0" Option "SuspendTime" "0" Option "OffTime" "0" EndSection
用xset修改DPMS和屏保设定
可以用官方仓库中xorg-xset提供的xset
工具关闭屏幕。注意:如果要在shell中关闭显示器,需要在命令前面加上 sleep 1;
. 例如:
sleep 1; xset dpms force off
To control Energy Star (DPMS) features (a timeout value of zero disables the mode):
xset -dpms Energy Star features off xset +dpms Energy Star features on xset dpms [standby [suspend [off]]] xset dpms force standby xset dpms force suspend xset dpms force off xset dpms force on (also implicitly enables DPMS features)
xset屏保控制
你可以用xset控制你的屏保:
xset s [timeout [cycle]] xset s default xset s on xset s blank xset s noblank xset s off xset s expose xset s noexpose xset s activate xset s reset
查看当前设置
$ xset q ... Screen Saver: prefer blanking: yes allow exposures: yes timeout: 600 cycle: 600 DPMS (Energy Star): Standby: 600 Suspend: 600 Off: 600 DPMS is Enabled Monitor is On
例子
关闭DPMS
xset -dpms
禁止屏幕变为空白
xset s off
关闭DPMS并防止屏幕变为空白
在看电影或幻灯片时有用:
xset -dpms; xset s off
立刻关闭屏幕
如果你要离开,无须等待超时之后屏幕自动关闭。可以运行如下xset
命令来立即关闭屏幕
xset dpms force off
Put screen into standby
xset dpms force standby
Put screen into suspend
xset dpms force suspend
Change Blank time from 5 min to 1 hour
xset s 3600 3600
xset display.sh
You could also copy this script:
/usr/local/bin/display.sh
#!/bin/bash # Small script to set display into standby, suspend or off mode # 20060301-Joffer case $1 in standby|suspend|off) xset dpms force $1 ;; *) echo "Usage: $0 standby|suspend|off" ;; esac
Make it executable (chmod u+x /usr/local/bin/display.sh
) and just run display.sh off
. For the latter to work you need to include /usr/local/bin
into your path.
DPMS interaction in a Linux console with setterm
The setterm utility issues terminal recognized escape codes to alter the terminal. Essentially it just writes/echos the terminal sequences to the current terminal device, whether that be in screen, a remote ssh terminal, console mode, serial consoles, etc.
setterm Syntax: (0 disables)
setterm -blank [0-60|force|poke] setterm -powersave [on|vsync|hsync|powerdown|off] setterm -powerdown [0-60]
防止屏幕关闭
可以运行以下命令, 并使其自启动(如添加到 /etc/rc.local):
$ setterm -blank 0 -powerdown 0
也可以通过下列命令禁止终端清空:
# echo -ne "\033[9;0]" >> /etc/issue
Pipe the output to a cat to see the escapes
$ setterm -powerdown 2>&1 | exec cat -v 2>&1 | sed "s/\\^\\[/\\\\033/g"
Pipe the escapes to any tty (with write/append perms) to modify that terminal
Note the use of >> instead of >. For permission issues using sudo in a script or something, you can use the tee program to append the output of setterm to the tty device, which tty's let appending sometimes but not writing.
$ setterm -powerdown 0 >> /dev/tty3
Bash loop to set ttys 0-256
$ for i in {0..256}; do setterm -powerdown 0 >> /dev/tty$i; done; unset i;
Troubleshooting
xset的DPMS设置在xscreensaver不起作用
xscreensaver用它自己的DPMS设置。 请看xscreensaver的设置以获取更多信息。
xscreensaver DPMS
你可以通过编辑~/.xscreensaver
以设置xscreensaver的DPMS设置,或者使用xscreensaver-demo.
timeout: 1:00:00 cycle: 0:05:00 lock: False lockTimeout: 0:00:00 passwdTimeout: 0:00:30 fade: True unfade: False fadeSeconds: 0:00:03 fadeTicks: 20 dpmsEnabled: True dpmsStandby: 2:00:00 dpmsSuspend: 2:00:00 dpmsOff: 4:00:00