1

I had this server which after 10 minutes would blank the screen and the monitor would go into sleep mode.

I added consoleblank=0 to the kernel parameters in order to avoid this.

My main issue with it is that I'm not sure how to wake up the screen. As I understand it, a keyboard interaction is necessary to archive this, but what if I don't know what is running behind the blank screen? It could be a prompt waiting for a key press in order to execute some command.

What is the proper way to unblank the screen with the keyboard with a guarantee that this will not be interpreted as input by any program?

2 Answers 2

3

There is a private control sequence that can be sent to a kernel virtual terminal (i.e. one of the /dev/ttyN devices, not to be confused with the console, /dev/console) to unblank the screen. You can look it up in the console_codes manual and just write it to that device with (say) printf.

Or you can use the util-linux command that emits the control sequence for you:

TERM=linux setterm --blank poke < /dev/tty0

In fact, it doesn't emit the control sequence. It uses a peculiar-to-Linux-KVT-devices ioctl() on its standard input. Yes, standard input. Really. Its manual nowhere hints that this is the case for some, but not all, of setterm's functions. That would be too easy and predictable.

Note that my portable setterm does not replicate stuff like this that is peculiar to the Linux built-in terminal emulator. You need the util-linux one for this.

Further reading

  • Jonathan de Boyne Pollard (2018). setterm. nosh Guide. Softwares.
1

Press Shift, Caps Lock, or Ctrl. "Modifier" keys do not cause actions to be performed, except in some games.

  • If someone leaves their game idle / unpaused for ten minutes, they are not seriously concerned about it.
  • In the case of a server text console, you are probably not concerned with games.

A lot of people use this trick. If software or configuration breaks this assumption, it will be criticized.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .