About the Linux console & DPMS

I wanted to have the console DPMS working which now a days is still turned off by default in your text Linux consoles.

Searching on the net I found the codes to use and it took me to the 'console_codes' manual page. This one is on most Linux system and you can view it with the following command line:

	man console_codes

If you search for "blank" or "VESA" or "powerdown" you should find the part of interest. To search type a slash (/) and the word you are searching for. Note that you can search the next iteration using the character 'n' in case what you see looks wrong.

Well, of course, there is a copy of the part of interest:

	Linux Console Private CSI Sequences
		The following sequences are neither ECMA-48 nor native VT102.  They are
		native to the Linux console driver.  Colors are in SGR parameters: 0  =
		black,  1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 = cyan,
		7 = white.

		ESC [ 1 ; n ]       Set color n as the underline color
		ESC [ 2 ; n ]       Set color n as the dim color
		ESC [ 8 ]           Make the current color pair the default attributes.
		ESC [ 9 ; n ]       Set screen blank timeout to n minutes.
		ESC [ 10 ; n ]      Set bell frequency in Hz.
		ESC [ 11 ; n ]      Set bell duration in msec.
		ESC [ 12 ; n ]      Bring specified console to the front.
		ESC [ 13 ]          Unblank the screen.
		ESC [ 14 ; n ]      Set the VESA powerdown interval in minutes.
  

Okay?! What's all of that?! Simple, send the command 'ESC [ 14 ; 10 ]' and 10 minutes after the blank, poof! the monitor will be shutdown in powersave mode. Very useful in your burning hot appartment on the last floor right under the roof!!! But probably not enough.

I actually also change the blank timeout so the console goes blank really fast and I don't need the beeps thus I put a bell duration of zero (which has the effect of turning off the bell, yes.) The following is how I send these commands at boot time.

  • I create a file named /etc/init.d/console with the following code
  • (note that you need to login as root in order to do the following)

    	#!/bin/sh
    
    	# See `man console_codes` for more info
    
    	# No beep in console (duration = 0 msec)
    	echo -e "\033[11;0]" >/dev/console
    
    	# Use DPMS in console (all monitors I have support that)
    	# Blank screen after 5 min.
    	echo -e "\033[9;5]" >/dev/console
    	# Powerdown after 5 min.
    	echo -e "\033[14;10]" >/dev/console
      

    Don't forget to make the file executable with:

    	chmod 755 /etc/init.d/console

    Note the comments in the file? Good. The "\033" is the ESC code in octal. The -e option is necessary so the echo commamd transforms the "\033" into an escape code. Some people also use -n since it should be useless to also send an end of line for these commands to take effect. And the console device is the one which needs to be changed and that's where we're sending the commands.

  • I create a link in the different rc directories:
  • 	ln -s ../init.d/console /etc/rc3.d/S33console

    The letter S means run at startup. The number 33 is a priority/order. Anything with a smaller number will be started before. Anything with a larger number will be started after. The console setup can happen really early if you want.

    You can try to run the script by hand first (you need to be root for that too).