1

I use my laptop with multiscreen: laptop screen on one side, my TV displaying my media center (Kodi) on the other side. Problem, when I use my media center to watch a movie, the laptop screen never switch to sleep mode.

I'm looking for a command to sleep the laptop screen, but ONLY this screen, and go out of this mode by using the touchpad. I was thinking to use xrandr, but it seems I can only deactivate (with option --off) the screen, and not just sleep it.

Any idea that would help?

Jacob Vlijm
  • 82,471
  • 12
  • 195
  • 299
cyanat
  • 29
  • 3

2 Answers2

3

Toggle- dim a specific screen

The command to dim the screen (not switch off, but not "sleep" either) would be:

xrandr --output $monitor --brightness 0

You can however easily toggle- dim the targeted screen with a keyboard shortcut. Add the script below to a shortcut:

#!/bin/bash
# --- set your monitor below
monitor=VGA-0
# ---
if [ -z "$(xrandr --verbose | grep 'Brightness: 0.0')" ]; then
  xrandr --output $monitor --brightness 0
else
  xrandr --output $monitor --brightness 1
fi

To use

  • Copy the script into an empty file, save it as dim_screen.sh, and make it executable
  • In the head of the script, set the name of your targeted screen. Run the command xrandr to find out if you don't know.
  • Add it to a shortut key: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
    /path/to/dim_screen.sh

Explanation

The test:

[ -z "$(xrandr --verbose | grep 'Brightness: 0.0')" ]

will see if the command xrandr --verbose | grep 'Brightness: 0.0' has an output, in other words, if your screen is dimmed. If so, it will set the targeted screen to "normal" brightness (1.0):

xrandr --output $monitor --brightness 1

...else it will dim the screen with the command:

xrandr --output $monitor --brightness 0

Note

It seems impossible to only put a specific screen to sleep. This answer is written, assuming you want the screen, dimmed, but switching it off, including the black out of both screens, is too much a fuzz.

Jacob Vlijm
  • 82,471
  • 12
  • 195
  • 299
  • This answer worked great for me with one exception. In Ubuntu 16.04 I can’t seem to use “/path/to/dim_screen.sh” to create a shortcut key. I had to put the script in the search path and use just “dim_screen.sh” to make it work but work it does. +1 – bashBedlam Jul 14 '16 at 16:20
  • Hi! In fact FN+F6 is exactly what I need, but I have read that it is purely hardware so it seems that we can't use an equivalent command in shell, or we can't simulate the FN key to reproduce it in a script. For the moment, your response is the closest solution I have found. I have also improved it (accordfing to my needs) by using the command xbacklight after your xrandr command: `xbacklight -set 0` – cyanat Jul 15 '16 at 20:42
  • @user3166173 If you'd really want it time- and touchpad triggered, it can be done. It would require a background process though. – Jacob Vlijm Jul 16 '16 at 06:17
  • @JacobVlijm I don't see what you mean, can you be more specific? – cyanat Jul 16 '16 at 09:47
  • @user3166173 in your original question, you mention waking up by touchpad event. – Jacob Vlijm Jul 16 '16 at 14:44
0

From How do I turn off the backlight but leave the LCD on?:

$ sudo -i
# Turn backlight off
echo 4 > /sys/class/backlight/intel_backlight/bl_power
# Turn backlight on
echo 0 > /sys/class/backlight/intel_backlight/bl_power
exit
$

I've just tried this and it works fine on my laptop.

WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401