10

I use xset to turn off my screens like this:

xset dpms force off

Is there any way to turn off a single screen when you have more than one associated with the same X display?

  • @myrdd: Could you please explain what you would like to see improved specifically? – David Foerster Dec 19 '17 at 22:39
  • I'd like to know details: (a) Is the desired feature technically possible?—That is, to "turn off" individual screens (I do not mean xrandr [...] --off)— (b) Are there any dependencies?—That is, does the graphics card chipset and/or the driver need to have a specific feature?— (c) Given the desired feature is not yet available (as a CLI command), what would be the next steps? – myrdd Dec 20 '17 at 6:04
4

If you are using stock Ubuntu Desktop you should be able to use System > Preferences > Monitors. This should show all of your monitors, click on the one you wish to disable, and then use the 'on/off' radio buttons to disable that specific monitor.

If you want to do this from the command line you should be able to use xrandr --output <name> --off to disable the output which should trigger the monitor to power down.

  • The problem is that when you're using Nvidia TwinView, both screens appear as one to both xrandr and xset, so you can't turn off the monitors individually. Also, Gnome Monitor Preferences is disabled and you have to use the Nvidia driver control instead. When you disable one of the monitors with nvidia-settings, it fully disables the monitor, jamming all of your windows on the other screen. I just want to shut one monitor off to watch a movie on the other. – Neil Nov 21 '10 at 15:15
  • @Neil It's probably useful to add your hardware information to the question and tag it with nvidia too. – Jorge Castro Nov 22 '10 at 2:17
  • 1
    @JorgeCastro it's not related to the hardware and TwinView: there appears to be no way to turn off a screen individually when it's on the same $DISPLAY, except from removing/disabling it from the RandR config. We want to turn off e.g. the laptop screen, but keep any windows there. – blueyed Mar 11 '15 at 15:58
  • @muru you are an editing monkey! I keep seeing your edits. – MathCubes Dec 21 '17 at 2:34
2
+25

Problem with existing answer

Although there was an answer seven years ago with three up-votes it wasn't accepted because it causes all open windows on the shut-off display to migrate to the remaining active display(s).

Software based brightness

On a laptop you can control brightness through the graphics card controlling the LCD panel. With external TV's and monitors you need a software solution to turn brightness down to 0. Turning it to zero is closest I've come to the illusion of turning it off whilst keeping the active windows on that external display.

Sony TV bash script

Here's one of three scripts I've written:

#!/bin/bash

# NAME: sony
# PATH: /mnt/e/bin
# DESC: Set brightness of Sony TV
# DATE: Dec 9, 2017.

if [[ $# -ne 1 ]]; then
    xrandr --verbose | grep -A5 "^HDMI-0" > /tmp/sony
    head -n1 /tmp/sony
    echo "$(tput setaf 1)" ; tail -n1 /tmp/sony ; echo "$(tput sgr0)"
    rm /tmp/sony
    echo 'One argument required for brightness level, e.g. "sony .63"'
    echo 'will set brightness level of Sony TV to level .63 using xrandr'
    exit 1
fi

xrandr --output HDMI-0  --brightness "$1"

To turn off the display you would use sony 0

Calling script with no parameters

When you call the script with no parameters it displays the xrandr screen name along with the current brightness in red. You can change the red color to another by modifying this line:

echo "$(tput setaf 1)" ; tail -n1 /tmp/sony ; echo "$(tput sgr0)"

After setaf change the 1 to:

  • 2 for green
  • 3 for orange
  • 4 for blue, etc.

Modifying and installing script

Change the two occurrences of HDMI-0to match your screen name. You can get a list of all your screens typing xrandrin the terminal.

Place the script in a directory in your path such as:

/usr/local/bin/sony

Mark the script as executable using:

sudo chmod a+x /usr/local/bin/sony

Choosing which directory:/usr/local/bin vs ~/bin

When you create scripts in /usr/local/bin you must use sudo powers. A better alternative is to use the directory ~/bin which is shorthand for /home/YourUserID/bin:

  • create the directory ~/bin
  • close your terminal and reopen it.
  • the newly created directory is now in your path.
  • all the scripts you create in ~/bin can be created with your regular permissions.
  • to enable execution of your scripts you just need to use chmod +x rather than chmod a+x (the a meaning all users)
  • Thank you for your answer. I didn't know the xrandr [...] --brightness option. Note that you've talked about Sony displays in particular, but --brightness should work for any other display as well. I've tested --brightness on my laptop, and it did work. However, --brightness 0 did not turn off the backlight…—I've also tested --brightness on my desktop computer: unfortunately, the screen(s) kept black only for 1 or 2 seconds. After those 1–2 seconds the brightness is reset automatically. I suppose whether it works is highly dependent on the gpu+driver+screen combination. – myrdd Dec 25 '17 at 19:13
  • @myrdd I actually have three scripts sony, toshiba and alien for two external displays and built-in laptop display. Yes the backlight doesn't turn off so you don't get "pure black" but it's a close work-around. The 1 to 2 second automatic reset doesn't effect any of my displays but I was running nVidia drivers for hardwired nVidia HDMI port and nVidia driver taking control of Intel HD530 iGPU two screens--Thunderbolt3 and built-in. – WinEunuuchs2Unix Dec 25 '17 at 19: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.