While having two or more monitor working together, Is there any way to put a single one of them on standby/suspend by issuing a command like: xset dpms force suspend
? or having a time set for that purpose like: xset dpms 100 0 0
which works on these monitors separately?
I've got two monitor working along each other, eDP1 (My Laptop) and VGA1 (An External monitor).
I want each of them to go into suspend/standby mode separately if I'm not directly interacting with them, suppose I'm watching a movie on VGA1, and for an hour and half eDP1 is on doing nothing.
I'm not interested in using xrandor --off --output eDP1
because it's not fast enough to work with.
I want my monitor to be ready to work, with a simple mouse movement so I'm able to switch between them fast.
- Running: Ubuntu 18.04
- Window Manager: OpenBox
Controlling individual monitors is not possible with xset ( and X11 actually)
As the title suggests, it is not possible for reasons of how
xset
is built and due to the X11 functions it uses. If we look at the source code,xset
callsDPMSForceLevel(dpy,DPMSModeSuspend)
(line 557), and the display variabledpy
comes fromXOpenDisplay()
function ( line 203 ), and that is by definition:In other words,
xset
applies settings globally to the whole display, not individual Screens. It'd be necessary to changexset
source code in order for that to work. DPMS extensions themselves mostly seem to only call whole display, not individual screens, so it is not possible to even write custom code with X11 library.Manually controlling that setting via
/sys
subsystem also doesn't appear to be workingScreens also are taken out of DPMS mode when key or mouse events occur, so considering that you may want to move your mouse or use keyboard, either of those actions would cause the monitor to leave DPMS mode.
Alternative workarounds
Best alternative (and actually physically working solution) is
xrandr
- it could be used to control the individual "outputs". In particular,will set that output off. Yes, you've mentioned that you don't want to use this solution since it is not fast enough, however so far it is the best one available. It has couple of advantages:
xset
The
xrandr --output VGA-1 --brightness 0.1
will colorize the screen in such way that it appears off, even though--brightness
is a software solution, so the display is not actually dimmed at hardware level, nor it is off on hardware level. However, it does the job of blanking a screen and is also resistant to key/mouse events.I've looked source code of Mate and Budgie screensavers, which are both forks of GNOME screensaver, however in either case they seem to be a software solution, since there's no mention of DPMS in the source code.
Temporary comment
xrandr
. On a longer test, this worked out pretty badly. Not so much the switching off failed, but at reactivating the screen, screen layout was totally messed up. I'd be happy to post it to see if it works in your case however, but my advice is not to use it.In the script, I went back to setting brightness to zero instead.
Then what did I change in this version?
The idle time is now defined by both keyboard- and mouse activity by default. Waking up is also done by either one.
Automatically dim inactive screen
As said by my fellow answerers, switching screens off from cli separately is a challenge at best, and I didn't find an option either.
What I did find is a way to automatically dim all screens, except the one where the mouse is, after x time.
Here we go
How to set up
Set up is straightforward:
Make sure you have both
python3-gi
andxprintidle
installedCopy the script above into an empty file, save it as
dim_inactive
, and make it executableRun it by the command:
an example:
will dim all screens where the mouse is not after two minutes
Additional information / explanation
For years I had my laptop setup such that when lid is closed laptop would suspend and external monitors would go blank.
For your reason of wanting to watch a video for 90 minutes on external monitor and have laptop screen go blank I changed lid close option to "Do Nothing":
I'm not using DPMS for external monitors but you could check your settings with
xset q
command:Notice these lines:
prefer blanking: no
Also notice these lines:
DPMS is enabled
to set monitor toStandby
when desired.Hopefully other users have used these options and post a detailed answer for you.
How about simply closing the laptop?
Why?
These two monitors are one display area so turning one off will create a number of issues like screen redrawing, applications moving to the main monitor, ...
(I went down that road a few years ago and the only reliable way I found of doing what you want to do is to push the button on the external monitor or close the laptop)
Just ensure you set these power settings with
gsettings set
:If the monitor has ddc that can work - it's relatively slow, too, but about the only way to reduce power in a ccfl backlit monitor without xrandr. Unfortunately only half of my monitors implement it.
You can easily connect i2c buses to outputs looking at the /sys/class/drm/card* directories Sergiy mentioned above (i. e. their i2c* subdirs).
So, "ddccontrol dev:/dev/i2c-4 -r 0xd6 -w 4" sets it to Standby, "ddccontrol dev:/dev/i2c-4 -r 0xd6 -w 1" sets it to On again.
I have cronjobs set up including getIdle from https://github.com/IonicaBizau/screensaver/blob/master/getIdle.c which gives the X idle time in ms.
You should probably add your user to the i2c group or otherwise enable access to the ddc buses.
One other quirk: while the ddc control is labeled "Power", at least with my monitor I can't use it to determine the actual power status - if I turn the monitor off manually, it still says "On" and I can't turn it on via i2c.