Laptop with external HDMI monitor: screen off/on loop [closed]

I'm running Ubuntu 16.04 on my laptop, and I have an external monitor connected via HDMI. Normally, my screen turns off after 10 minutes of inactivity or after I lock the screen. This sets off a series of events:

  1. The laptop screen turns off.
  2. The external monitor goes to sleep.
  3. Ubuntu seems to think the external monitor has been detached, and it refreshes the display.
  4. My laptop screen turns back on, in single display mode.
  5. The external monitor turns back on, and the display refreshes again to dual display mode.
  6. After a period of inactivity, repeat from #1.

This happens over and over again indefinitely, preventing both displays from ever turning off. Since I rely on this feature to automatically lock my computer after inactivity, it's also a security concern.

Is there any way to prevent this problem?


The easiest way is to lock your screen after inactivity but not turn the screen off.

As per this answer: How do I prevent my display from turning off when screen is locked?, use this command:

gsettings set org.gnome.desktop.screensaver idle-activation-enabled false

Your screen will still lock after inactivity but the password prompt will stay up and the screen won't turn off.

Not the perfect solution but hopefully one that addresses your security concerns without the annoying loop.


This problem was resolved when I upgraded to Ubuntu 18.04.