The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 13,887β€…    Votes:  6β€…
Tag : multiple-monitors  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/988203
Title: Is there a way to turn off individual screens?
ID: /2017/12/21/Is-there-a-way-to-turn-off-individual-screens_
Created: December 21, 2017    Edited:  June 12, 2020
Upload: April 8, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


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.

Short version

From the command line (without scripts) use:

$ xrandr | grep " connected"
HDMI-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 1107mm x 623mm
eDP-1-1 connected primary 1920x1080+3840+2160 (normal left inverted right x axis y axis) 382mm x 215mm
DP-1-1 connected 3840x2160+1920+0 (normal left inverted right x axis y axis) 1600mm x 900mm

This shows you the list of monitor names assigned by xrandr. Now if you want to set DP-1-1 brightness off use:

xrandr --output DP-1-1 --brightness 0

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:

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:

⇧ Edits to nvidia-xconfig not taking hold after restart? Stop emailing me bad sudo password attempts  β‡©