0

I'm running some UI automatic testing in which the pointer is moved to perform/simulate user actions, which is executed after some time when the display is OFF.

I want to leave the screen OFF while running these tests, but stop the tests if the user interact with the keyboard or mouse (or just the keyboard)

I know how to turn off mouse & keyboard, and how to turn the display on and off, but that is not what I need here. I would like to prevent waking up the screen during such tests.

I'm using Ubuntu 18.04, but if I can get a more generic solution, it would be great.

Note: I found that vbetool can turn off the display without waking up with mouse or keyboard input, but its not working (display is not turning off).

Update: My best shot so far is to use xrandr --output HDMI-0 --off (for example), as it completely disables the screen.

1

This is what I use daily, which goes through usual X11 driver rather than VGA BIOS, no root access needed:

xrandr --output LVDS1 --off
  • If your display is not a built-in LCD screen, substitute LVDS1 with relevant port from you see from plain xrandr command without parameter. It is usually something along the line of VGA1, HDMI1, or DP1.

This doesn't "standby" the screen in a sense of DPMS-style power save however; it actually disable the specified video output, and detach it from your display server.

The side effect of this headless state is your "desktop" would shrink to the minuscule size; around 320x200 pixel; you can press PrintScreen key to see what it looks like. This probably won't work for your usability tests, so...


To prevent the shrinkage; add --fb option to set the virtual "desktop" size after your video output is off:

xrandr --output LVDS1 --off --fb 1024x768
  • Substitute LVDS1 with the relevant output port, and 1024x768 with your current resolution.

Once your video output is disabled and virtual "desktop" size is all set, you can commence your tests.

At the time you would like to come back, re-enable your output:

xrandr --output LVDS1 --auto
  • Substitute LVDS1 with the relevant output port.
  • This will set the output to default monitor-native resolution. If you would like to restore it to a specific resolution, substitute --auto with something like --mode 1024x768 (replace 1024x768 with your desired resolution).

P.S. My answer is tested on Debian 7.0 32-bit GNU/Linux system, Xorg 1.12.4 display server, Intel i915 graphics.

1
  • Thanks! Your explanation is very useful! The only issue we found with this approach is that the user doesn't know that there is a test in progress (and may think the system is down or unresponsive). We can play a sound to indicate that the system is on testing or we can keep the screen on during testing (so the user knows what is happening), disabling any input and turning off the screen after finishing. We are still evaluating the situation. Great answer! – lepe Oct 9 '19 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.