Turning off dual monitors with "xset dpms force off" does not work - why?
What exactly are you trying to accomplish? For managing monitor usage you can/should use the randr extension where xrandr
would be the weapon of choice in scripts.
xrandr -q
shows all outputs of your computer and some info about connected monitors. To disable an output you would put something like xrandr --output=HDMI1 --off
. In your case you have to replace "HDMI1" with whatever xrandr -q
tells you your outputs are named. With your output disabled X does not use this monitor anymore (at all) and it will most likely enter a sleep state.
If you actually want the monitor to turn off, your problem is that xset
does neither know nor care about how many monitors you have hooked up to your computer, because xset
talks to Xservers, not their components and definetly not hardware. This means xset
sends exactly one "dpms force off" request and that request is (processed and) sent to one of your monitors by the Xserver. I'd guess it sends it to your primary monitor, i.e. the one connected to the output that appears first in the list shown by xrandr -q
. That's the same monitor your gnome panel lives on, if you're using gnome.
In effect I'd guess you have to issue your xset
request twice. If that doesn't help immediately I'd assume you need to be explicit about the issue which of your attached monitors is primary and which is not.
xrandr
allows you to set the primary output/monitor by the use of the --primary
option. If your outputs are HDMI1
and HDMI2
, I'd try:
xrandr --output HDMI2 --primary
xset dpms force off
xrandr --output HDMI1 --primary
xset dpms force off
Check the output of xrandr -q
and write a script that turns off your monitors in the reverse order they are listet, that is bottom up. The reason for that is, that while (x)randr is supposed to be able to arbitrarily make outputs the default output I wouldn't/don't trust it to work that flawlessly, especially if there are closed source drivers involved. By working through your monitors in reverse order you turn off the "natural" primary monitor last and if things go wrong, having the "natural" primary monitor available is your best shot at having a fully functional Xserver.