Display Power Management Signaling

From ArchWiki
Revision as of 19:40, 3 May 2015 by Indigo (talk | contribs) (move short troubleshoot item to main section to give it more prominence. It is the only TS item, so we might just refer to it directly in the content)
Jump to: navigation, search

zh-CN:Display Power Management Signaling DPMS (Display Power Management Signaling) enables power saving behaviour of monitors when the computer is not in use. For details on each timeout, see [1]. Note that some monitors make no difference between various DPMS modes.

Setting up DPMS in X

Note: As of Xorg 1.8 DPMS is auto detected and enabled if ACPI is also enabled at kernel runtime.

Add the following to a file in /etc/X11/xorg.conf.d/ in the Monitor section:

Option "DPMS" "true"

Add the following to the ServerLayout section, change the times (in minutes) as necessary:

Option "StandbyTime" "10"
Option "SuspendTime" "20"
Option "OffTime" "30"
Note: If the "OffTime" option does not work replace it with the following, (change the "blanktime" to "0" to disable screen blanking)
Option         "BlankTime" "30"

An example file /etc/X11/xorg.conf.d/10-monitor.conf could look like this.

Section "Monitor"
    Identifier "LVDS0"
    Option "DPMS" "false"
EndSection

Section "ServerLayout"
    Identifier "ServerLayout0"
    Option "StandbyTime" "0"
    Option "SuspendTime" "0"
    Option "OffTime" "0"
EndSection

Modifying DPMS and screensaver settings using xset

It is possible to turn off your monitor using the xset tool which is provided by the xorg-xset package in the official repositories.

Note: If using this command manually in a shell you may need to prefix it with sleep 1; for it to work correctly. For example:
$ sleep 1; xset dpms force off

Example commands:

Command Description
xset s off Disable screen saver blanking
xset s 3600 3600 Change blank time to 1 hour
xset -dpms Turn off DPMS
xset -dpms; xset s off Disable DPMS and prevent screen from blanking
xset dpms force off Turn off screen immediately
xset dpms force standby Standby screen
xset dpms force suspend Suspend screen

To query the current settings:

$ 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

See xset for all available commands.

Warning: xscreensaver or xfce4-power-manager use its own DPMS settings and override xset configuration. See XScreenSaver#DPMS settings for more information.

xset display.sh

Alternatively, copy this script inside your $PATH and make it executable (chmod +x):

/usr/local/bin/display.sh
#!/bin/bash

case $1 in
    standby|suspend|off)
        xset dpms force $1
        ;;
    *)
        echo "Usage: $0 standby|suspend|off"
        ;;
  esac

As screensaver settings do not persist across X restarts, consider to automatically start the script.

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]
Note: If you haven't already read the brief DPMS article linked to below, please skim it to understand how DPMS can be used in the console the same as in X.

Prevent screen from turning off

You can run this command:

$ setterm -blank 0 -powerdown 0

Alternatively you can disable console blanking permanently using the following command:

# 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

$ setterm -powerdown 0 >> /dev/tty3
Note: >> is used 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.

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 settings do not work with xscreensaver

See also