xflock4 needs a 'sleep 1' before 'xset dpms force off' to prevent backlight from immediately reactivating

Bug #1802138 reported by Chris Rainey on 2018-11-07
This bug affects 1 person
Affects Status Importance Assigned to Milestone
In Progress
xfce4-session (Ubuntu)

Bug Description

Without a 'sleep 1' before +dpms command, slock or xtrlock, etc. will cause a laptop backlight to immediately reactivate.

    description: Notebook
    product: 4180AP3
    vendor: LENOVO
    version: ThinkPad T420

          description: BIOS
          vendor: LENOVO
          physical id: d
          version: 83ET82WW (1.52 )
          date: 06/04/2018
          size: 128KiB
          capacity: 8128KiB
          capabilities: pci pnp upgrade shadowing cdboot bootselect edd int13floppy720 int5printscreen int9keyboard int14serial int17printer int10video acpi usb biosbootspecification

             description: VGA compatible controller
             product: 2nd Generation Core Processor Family Integrated Graphics Controller
             vendor: Intel Corporation
             physical id: 2
             bus info: pci@0000:00:02.0
             version: 09
             width: 64 bits
             clock: 33MHz
             capabilities: msi pm vga_controller bus_master cap_list rom
             configuration: driver=i915 latency=0
             resources: irq:26 memory:f0000000-f03fffff memory:e0000000-efffffff ioport:4000(size=64) memory:c0000-dffff

ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: xfce4-session 4.12.1-3ubuntu4 [modified: usr/bin/xflock4]
ProcVersionSignature: Ubuntu 4.18.0-10.11-generic 4.18.12
Uname: Linux 4.18.0-10-generic x86_64
ApportVersion: 2.20.10-0ubuntu13
Architecture: amd64
CurrentDesktop: XFCE
Date: Wed Nov 7 10:11:37 2018
InstallationDate: Installed on 2018-11-04 (2 days ago)
InstallationMedia: Xubuntu 18.10 "Cosmic Cuttlefish" - Release amd64 (20181017.2)
SourcePackage: xfce4-session
UpgradeStatus: No upgrade log present (probably fresh install)

As noted at http://www.shallowsky.com/linux/x-screen-blanking.html calls to "xset dpms" need to be prefixed with "sleep 1":

    will blank the screen (or activate the screensaver program, if you're using
    one) after a delay of one second. You need the delay because X gets a little
    confused about the order of events; it will blank the screen but immediate
    un-blank it, thinking the activity of your typing the command happened
    recently enough to come out of screensaver mode.

    sleep 1; xset dpms force off

    will turn the screen OFF after a delay of one second. You can also use
    standby, suspend, or on instead of off.

Downstream bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776674

Created attachment 5915

I can reproduce the issue, but the patch does not work for me (Xfce 4.11, ArchLinux 64 bits, xscreensaver 5.32).

@OP, what screensaver do you use, and does the patch work for you?

@Other triagers, could you please test the patch?

@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..)

Hi Chris,

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.

Errata; after uninstalling xscreensaver, the patch still does not work.

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


The explanation:

"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.

In , Rgm-b (rgm-b) wrote :

Also see:


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.

thank you

In , Rgm-b (rgm-b) wrote :

Same problem with:


On my Cubietruck through its VGA adapter. I probably will get around to testing with HDMI tomorrow as well as testing on my Cubieboard2.

The usual: You set screensaver to use a blank screen, and lock the screen.

Screen blanks, but backlight stays on.

Chris Rainey (ckrzen) wrote :

Still happening in Xubuntu 18.10. I vote for adding the patch!

$ hostnamectl
   Static hostname: CKR-2
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 5c61c71187fa4ba4aa26bdd89516ee5a
           Boot ID: 9a2e3fb61f6d461d9b423cdeebaa4c57
  Operating System: Ubuntu 18.10
            Kernel: Linux 4.18.0-10-generic
      Architecture: x86-64

The attachment "sleep added." seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in xfce4-session:
importance: Unknown → Medium
status: Unknown → In Progress
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.