will blank the screen (or activate the screensaver program, if you're usingone) after a delay of one second. You need the delay because X gets a littleconfused about the order of events; it will blank the screen but immediateun-blank it, thinking the activity of your typing the command happenedrecently enough to come out of screensaver mode.sleep 1; xset dpms force offwill turn the screen OFF after a delay of one second. You can also usestandby, suspend, or on instead of off.
@Steve Yes the patch works for me using slock.
What exactly fails for you?
Does "sleep 1; xset dpms force off" successfully turn off the monitors on your system?
Do you have one of {xscreensaver-command,light-locker-command,gnome-screensaver-command} installed? If so, the xset dpms line in xflock4 is never executed.
(can't seem to change bug status back from needinfo..)
When I type xset dpms force off in a terminal, my screen is turned off. Xflock4, with or without delay, always fails to turn my screen off. I believe the screensaver is the culprit, it probably talks to the X11 server and causes it to wake up.
Can you try "slock & sleep 1; xset dpms force off"
Also try "sh -x /usr/bin/xflock4" and see if the xset line is actually being executed. It won't be if you have xscreensaver, light-locker or gnome-screensaver installed.
Ok, I've been a bit silly on that one. So, when having slock installed I reach this code path.
With the patch: 1 second delay, then a black screen
Without the patch: black screen immediately
Now, on desktops, when using a mouse, it's quite easy to trigger the mouse after the screen has been forced off. Still, a whole second is a bit excessive.
I'd like more developers to weight in before applying the patch.
Chris, thanks for writing the patch and bearing with me though. Of course if you can link to others complaining about the issue, and to more precise reasons why it is systematically happening for you, it'll increase the odds of people weighing in favour of your patch.
With the patch: 1 second delay, then a black screen
Without the patch: black screen immediately
slock will always show a black screen but is the monitor actually turned off with DPMS - my monitor shows "Entering power save mode" when this happens and turns off the back light.
Try this: in a terminal type "xset dpms force off" and press and hold the enter key for one second before releasing it. The key press event will cause the execution of the xset command, but then the release event will wake the monitor back up. The same happens with the ctrl-alt-delete shortcut.
Of course if you can link to others complaining about the issue
"You're using it manually from command line or xset is binded to some keyboard shortcut? On my brother laptop this command was binded to some keys and after that monitor was turned off and on again, because when he was releasing key next event was emitted. Turning it off after quick sleep solved problem: perl -e 'select(undef,undef,undef,.1)' && xset dpms force off - this perl expression do sleep for 0.1 sec."
The timeout has to be longer than the delay between a person pressing the enter key and then releasing it.
This is a real pain with my notebook screen not going off when locked. In a hotel room at night, I have to put a towel over the screen to get to sleep myself! When at my desk at home, the external monitor is brightly lit when locked, lighting up the whole room at night.
I am concerned about long-term effects on the backlight feature failing if not corrected.
Since I am running Fedora 21, please let me know what I have to do to test a patch.
@Simon: apologies, if your previous comment is directed at me. I'm currently on Ubuntu 19.04(Gnome 3) without a proper XFCE4 installation to test this on.
I do not see a problem in having even longer delay than a second. But, using "sleep 1; xset dpms force off" has still the problem that user may accidentally touch something so that display will become on again. Besides, it effectively disables Presentation mode user may have set using Power manager's panel item.
A better solution would be to change DPMS settings for the time such a screen locker is running to enable turning display off after reasonable time of inactivity from user, and restore previous settings, when user unlocks. This is possible by using a wrapper script.
That script has other modifications such as added screensavers and lockers and optionally using display power management for the locker user may have set in Xfconf. The script can be simplified notably, if hacking the DPMS settings for general lock command set in Xfconf is left out.
I have never got any feedback about the script.
Note: proper screensavers (that have a daemon running when lock command is called) should handle DPMS by themselves.
Note that even this improved xflock4 script never gets past xfce4-screensaver-command, because of bug 15945 which should be fixed ASAP. That is, if xfce4-screensaver is installed.
As for the previous attachment, at least with the gnome-screensaver available for Ubuntu 20.04 (version 3.6.1-11ubuntu4) 'gnome-screensaver-command --lock' exits with status 0 even if gnome-screensaver is not running so the script exits with 0 even if it does not lock the screen. One option is to remove gnome-screensaver from the script (see issue #17 (closed)) or to handle checking by 'gnome-screensaver-command --query'.