A Primer on Screen Blanking Under Xorg

X offers two modes of screen blanking: BlankTime and DPMS. Settings for both can be queried via xset -q.

BlankTime is "fake" screen blanking: it makes the screen black but the backlight and power supply stay on. It doesn't actually do anything to reduce the power usage. Think of it as a really boring screen saver. The timeout defaults to 10 minutes.

In more recent Xorg versions, like the 7.2 that comes with Ubuntu's "Gutsy Gibbon", BlankTime is gone, and instead there is a Screen Saver section, which includes the options prefer blanking, allow exposures, timeout, and cycle. It works differently, too: prefer blanking actually switches the monitor to powersave mode (the alternative, if you turn it off, is an ugly X cross-hatch pattern) and there doesn't seem to be any way to get the old "fake blank" behavior back. I don't know what the difference is between timeout and cycle; the manual page doesn't say, nor does anyone else. Gutsy sets them both to 600 seconds.

DPMS is display power management. It only works with displays that support that sort of power management (though I suspect most modern displays probably do). DPMS includes three settings:

Standby Time
In a CRT, this turns off the electron gun, but leaves everything else powered on so that the screen can recover quickly. The timeout defaults to 20 minutes.
Suspend Time
This turns off the monitor power supply in addition to the electron gun. By default this timeout is set to 30 minutes.
Off Time
This turns off all power to the monitor and is the most power conservative state. By default this happens after 40 minutes.

So the ten-minute screen blanking I've been seeing all along wasn't a power saving mode at all. It was just X turning the display black after the default ten minute timeout.

The Timeouts

Where do the timeouts come from?

The default values are built into X, and need not appear anywhere else. That's why, if you grepped for timeouts, you may not have found them.

They can also be set via xset. You can set the blank timeout with:

xset s blank
xset s 300
will tell X to use screen blanking after the system has been idle for 300 seconds (five minutes).

xset dpms 0 360 420
disables DPMS standby and sets the DPMS suspend time to 360 seconds and the off time to 420 seconds. In theory, this combined with the previous xset commands would first blank the screen at five minutes; then at six minutes, the display would go to suspend, turning off another minute later. In practice, this won't work for most people, as we'll see later. (DPMS through xorg seems only to toggle the screen-blanked state -- so if the screen was already blanked, it will actually turn back on! -- rather than going to a power saving state.)

But the timeouts can also be specified in the X configuration file: /etc/X11/xorg.conf. In the "Monitor" section, you need a line like:

        Option          "DPMS"
Then, in the "ServerLayout" section (for Xorg 7.2 and later, make a separate ServerFlags section instead), include lines like this:
        Option          "BlankTime"     "4"
        Option          "StandbyTime"   "0"
        Option          "SuspendTime"   "0"
        Option          "OffTime"       "5"
Caution: note the numbers are all small. xorg.conf needs times specified in minutes, not seconds as with xset.

If you're seeing a timeout that isn't one of the defaults, but isn't specified in xorg.conf -- as with the two-minute timeout which set me on this quest in the first place -- you may have to hunt around for a place that's calling xset dpms with a different set of timeouts. In my case, it turned out that Ubuntu Breezy sets the dpms timeouts in /etc/acpi/power.sh, which gets called at boot time. So anything you set in xorg.conf may well get overridden.

Hint: when debugging timeouts, try setting them to unusual numbers like 765 or 666 instead of 300 or 600. That makes it easier to be sure whether you're seeing your own numbers or something coming from a system setting somewhere else.

Testing the monitor blanking modes

Want to see what the various options look like? xset can do that too.
sleep 1; xset s activate
will blank the screen (or activate the screensaver program, if you're using one) after a delay of one second. You need the delay because X gets a little confused about the order of events; it will blank the screen but immediate un-blank it, thinking the activity of your typing the command happened recently enough to come out of screensaver mode.
sleep 1; xset dpms force off
will turn the screen OFF after a delay of one second. You can also use standby, suspend, or on instead of off.

Oops! It doesn't work!

Try it now (wiggle the mouse afterward to bring the screen back): sleep 1; xset dpms force off

Did your screen turn off? All the way? No backlight? Then be happy, and skip the rest of this document. Everyone else, read on.

It turns out that Xorg actually doesn't use DPMS when it's supposedly using DPMS, at least on a lot of systems. xset dpms force off merely makes the screen black; the backlight stays on.

Of course, the immediate suspicion is that my hardware doesn't support DPMS properly. It is, after all, an old S3 Savage video card. So how can I test that?

Testing, redux

Fortunately, there's an easy way: vbetool. This is the method Ubuntu's sleep.sh uses to turn the monitor off when suspending, and it works fine.

Verify that the backlight does indeed turn off with:

vbetool dpms off
(vbetool's dpms options also include on, standby, suspend and reduced.)

If the backlight turns off, the problem isn't the hardware: it's just that Xorg, for reasons unknown, isn't really using DPMS when it says it will. A little googling showed dozens of people reporting this on video cards from at least four different manufacturers, so it's not an isolated occurrence. Nobody seems to have an explanation or a cure. Some people say that eventually the backlight does turn off, but with a delay much much longer than the one that's set (e.g. they set the off timeout to 10 minutes, and their screen blanks at 10 minutes, then the backlight finally turns off at 30 minutes or an hour). That's not really very useful, and it doesn't even happen on all machines. On my laptop, even that doesn't seem to happen; the backlight stays on for as long as I've tested it.

A Workaround

So what if you really do want your backlight to turn off after a specific interval? There doesn't seem to be a way to get Xorg to do it directly. But you can cheat: Write a script that calls vbetool dpms off. Then set that script to be your screensaver.


More Linux tips
Shallow Sky home
...Akkana