17

This is the same question as this but for Raspberry Pi 3 / Raspbian.

I need a way to show black screen by running command in console by using SSH connection. Monitor should not go to standby I just need a black screen to hide everything that is on the screen. Screen should be black until I give another command to show screen content.

In Ubuntu this works:

xrandr -d :0 --output default --brightness 0

But in Raspbian nothing happens:

pi@media2:~ $ xrandr -d :0 --output default --brightness 0
xrandr: Gamma size is 0.

pi@media2:~ $ xrandr -d :0
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 1360 x 768, current 1360 x 768, maximum 1360 x 768
default connected 1360x768+0+0 0mm x 0mm
1360x768       0.00*
Glorfindel
  • 620
  • 1
  • 9
  • 16
JPX
  • 563
  • 2
  • 4
  • 13

2 Answers2

10

Method 1: Blank the screen without turning the power off to the HDMI port.

You might need to set the screen's default state to blank (I didn't):

xset -display :0 s blank

Turn the monitor to it's default state (black hopefully):

xset -display :0 dpms force off

Turn the monitor back on by hitting a key, moving the mouse, or using this command:

xset -display :0 dpms force on

Method 2: Turn off the HDMI port and back on. This may result in the monitor itself turning off, depending on the monitor's settings, because it's not getting any signal. Some TVs or Projectors may display an error message about no signal.

Turn it off:

tvservice -o

Turn it back on:

tvservice -p

The monitor might be blank or checkered until you force it to display:

xset -display :0 dpms force on

Method 3: This does not apply to RPi 3 with standard Raspbian, but some specialized situations and the original Pi might be able to use this alternative (depreciated?) method.

Find out what the monitor's name is by running:

xrandr -display :0 -q

We'll use the name CRT1 in this example to turn it off:

xrandr -display :0 --output CRT1 --off

And turn it on again:

xrandr -display :0 --output CRT1 --on

In all these methods, the part about -display :0 is redundant if your terminal is visible on the display you are trying to control.

Best of luck!

Jon Musselwhite
  • 794
  • 5
  • 17
2

Turn black screen saver on: xset -display :0 s blank xset -display :0 s reset xset -display :0 s activate

Turn it off: xset -display :0 s reset xset -display :0 s noblank

You don't need command xset -display :0 s blank and xset -display :0 s noblank if the default setting is blank. reset is neede in the case if you try to turn screen saver on and it's already on.

JPX
  • 563
  • 2
  • 4
  • 13