How to blank specific monitor in multimonitor environment?

DE: Xfce

EDIT: would be better say “blank” instead of "turn off"
EDIT2: Seems not possible, due limits of xset and X11? :

I hooked a second monitor using the HDMI output.
Usually, when I wanted to turn off the laptop’s monitor (LVDS1), I used to have two methods:

  1. close the laptop’s lid (in /etc/systemd/logind.conf I set HandleLidSwitch=ignore to do nothing: just turn off the screen: I can say it because as I almost close the lid, I can see that it simply turn off)

  2. using a bash script wich contain:
    xset -display :0 dpms force off

Now that I have the second monitor on HDMI, the second method (xset -display :0 dpms force off) turn off both screens instead of only the laptop’s monitor.

I am aware of xrandr --output LVDS1 --off to turn off the laptop’s screen and of xrandr --output LVDS1 --auto to turn on the laptop’s screen, but doesn’t work as expected: was better using xset -display :0 dpms force off, because to reactivate it I just had to move the mouse or press any key on the keyboard; furthermore, the xrandr method, deactivate my screens layout (HDMI extended on the right). xset instead and again, didn’t deactivate the screens layout.

So, currently:

  • Closing the lid, works as expected and flawlessly but I would use a bash script (which I can call with keyboard schortcut, also when I am distant from the laptop, thanks to wireless keyboad).
  • Such script was xset -display :0 dpms force off but turn off both screens (but as I’ve said is enough to move mouse or press keyboard to reactivate)
  • xrandr --output LVDS1 --off doesn’t work as I would and like: deactivate screens layout and I can’t reactivate the screen using mouse and keyboard as instead xset does.

There is a method to have the same behaviour of lid closing using a bash script? Or maybe by changing the xset script?

If you want to use a script, you can use xrandr option. You can make a script with a menu and the options you want, or make a script for any option. Then you can launch them with a shortcut. It’ll doesn’t matter if you can reactivate with the mouse , you’ll have a shortcut for that.
About the script, if you want a graphical menu you can read about kdialog(Qt) or dialog(Gtk), if you don’t, you can launch the menu in a terminal and choose any options with a key. Also you can use dmenu, it’s a menu for window managers but it’s in manjaro repos.
Here there’s one I have for that matter with dmenu

chosen=$(echo -e "$options" | dmenu -i -l 3 -p "Choose Monitors")

	case "$chosen" in 
		Laptop) xrandr --output eDP-0-1 --auto --output HDMI-0-1 --off ;;
		HDMI) xrandr --output eDP-0-1 --off --output HDMI-0-1 --auto  ;;
		DualMonitors) xrandr --output eDP-1-0 --auto --primary --output HDMI-0 --auto --right-off eDP-1-0 ;;

This is made for dmenu, I launch it with a shourcut. Adapt it for your needs.

Thank you for the hint (and so the useful script!) but as I’ve said, xrandr doesn’t work as I would, for my needs.

Would be interesting to kwon what happen in the system when the lid is closed, as this action trigger the screen blanking.


Would be interesting to kwon what happen in the system when the lid is closed, as this action trigger the screen blanking.<

Depend how you have configured the power manager app.

the xrandr method, deactivate my screens layout (HDMI extended on the right). xset instead and again, didn’t deactivate the screens layout.<

If you mean because this. You can solve it adding your own options to xrandr

Either way, you can change the xrandr command to the xset you need, the scripts works anyway

I edited /etc/UPower/UPower.conf by setting:

xrandr is not an option, since as I’ve said, by turning off the screen (instead of blanking it as xset instead does) it deatcivate my screens layout:
I set the HDMI screen to be an extension to the right; as I run the xrandr command, ok: the laptop’s screen goes black but the HDMI screen become a mirror instead of an extension.

That might very possibly be handled on a lower level.

I also suspect this: the only tracks I found in the journal logs, are:

nov 04 22:38:53 Probook systemd-logind[428]: Lid closed.
nov 04 22:38:54 Probook systemd-logind[428]: Lid opened.

There is very probably an input device with the name “Lid Switch” that reports the state of the lid, systemd watches the events to react appropriately.

By the way, if you want to turn off only the integrated display, isn’t setting the brightness to zero a viable workaround?

Yep, I am aware of this option, but despite the fact that the brighntess is set to 0, the screen is still bright.

Zero on some slider in the settings or zero in /sys/class/backlight/*/brightness? Because most of the time the settings application won’t let you go to the actual zero level. You can do that, however, by directly writing to the backlight class device’s brightness attribute.

By using xrandr --output LVDS1 --brightness 0; I mean to say that nothing is on the screen, but is not black as when is turned off.

I suggest you try directly writing the brightness level to the kernel:

echo 0 | sudo tee /sys/class/backlight/*/brightness

(if you have a backlight device in that folder, that is).

As I try (also logged in as root in the terminal) I always got: Permission denied
This happens for /sys/class/drm/card0-LVDS-1/intel_backlight/brightness and also for /sys/class/drm/card0-LVDS-1/dpms.

Can you control the backlight in the settings?

Sure: currently is at about 34% and when I set it to 0, well… Is to 0%.

And did you run exactly the command I sent?

Yes, adjusted for my system.

What if you run it without any modification?

As I try to edit anything under /sys/class/drm/ I always got “Permission denied”.

You aren’t trying echo 0 > /sys/class/.... by any chance?