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*
3
  • What happens if you give a gamma value, like --gamma 0:0:0?
    – Bex
    Commented Jan 5, 2017 at 9:06
  • Use framebuffer fb with a solid image?
    – Piotr Kula
    Commented Jan 5, 2017 at 9:19
  • @bex pi@media:~ $ xrandr -d :0 --output default --gamma 0:0:0 xrandr: Gamma size is 0. and nothing happens on Raspberry's HDMI output.
    – JPX
    Commented Jan 5, 2017 at 10:12

2 Answers 2

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!

10
  • This doesn't work. Same gamma error: pi@media:~ $ xrandr -d :0 --output default --off xrandr: Failed to get size of gamma for output default
    – JPX
    Commented Jan 5, 2017 at 14:04
  • That's not the command I suggested. You're using -d :0 --output default instead of --output CRT1 or whatever your display's name is. You seem to be trying to accept the default monitor instead of explicitly using its name. Please humor me and try using the name you get from calling xrandr -q in place of CRT1 in the other commands I suggested. No other changes to the command. Commented Jan 5, 2017 at 14:42
  • I'm updating my answer because I can't get that to work either. I've found a way to blank the screen, but it will turn right back on if you move the mouse or hit a key on the keyboard. Commented Jan 5, 2017 at 15:23
  • 1
    And now I've included a method which turns the power to the monitor off as well. Commented Jan 5, 2017 at 16:01
  • Have you actually tried this on a Pi? The hdmi code on the Pi doesn't support most xrandr commands.
    – Milliways
    Commented Jan 5, 2017 at 23:11
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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