External monitor not detected by Ubuntu 19.04 after sleep

I am running Ubuntu 19.04 on a Dell XPS-13 9380 (Intel graphics). I have an external monitor connected to a USB-C hub via HDMI. The monitor is always detected and works great when I plug it in after a fresh boot. While the computer is awake, I can unplug the hub, plug it back in, and the monitor will come back up. Here is the output of xrandr when the monitor is working:

Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 290mm x 160mm
   1920x1080     60.03*+  48.03  
DP1 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 530mm x 300mm
   1920x1080     60.00*+  50.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1680x1050     59.88  
   1280x1024     60.02  
   1440x900      59.90  
   1280x800      59.91  
   1152x864      75.00  
   1280x720      60.00    50.00    59.94  
   1024x768      70.07    60.00  
   800x600       60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       66.67    60.00    59.95    59.94  
   720x400       70.08  
DP2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

At the end of the day, I unplug the computer and close the lid to put it to sleep. When I come in the next day, wake it up, and plug the hub back in, the monitor is not detected. (The USB devices on the hub work fine, so I know the port is working on some level.) Here is xrandr when the monitor is not detected:

Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 290mm x 160mm
   1920x1080     60.03*+  48.03  
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

Running xrandr --auto at this point has no effect. If I restart the computer in this state, the monitor is always detected again after reboot, but it's annoying to have to restart the machine every morning.

Here's the interesting bit: if, while I'm restarting, I press a key to get the verbose shutdown output, I can see that just before the shutdown sequence finishes, the content moves over to the external monitor! Unfortunately it goes by too fast for me to tell what happened right before the monitor was detected, but it strongly suggests to me that there's something in software that's "stuck" after sleep, and that there ought to be a way to unblock it without rebooting the whole machine. (Of course, if I can just prevent the problem completely, that'd be even better.)

Based some similar questions on askubuntu, I tried switching my display manager from gdm3 to lightdm, but that did not help.

What else can I do to diagnose or fix this problem?

UPDATE: I have observed that if I remember to plug in the USB hub before opening the computer's lid, the monitor generally comes up fine. But it never works if I plug the hub in after waking up the computer.


I had this same problem, and this post helped me!

Install laptop-mode-tools: sudo apt-get install laptop-mode-tools, open the UI, and enable Enable module video-out

That's it! It solved my problem!


So, I cannot post comments yet, but I still think this information could be useful:

I have a Dell XPS-13 9370 with the same problem, which occurred after installing 19.04. The external monitor is not recognized after sleep/lock mode. xrandr --auto does reconnect the monitor, but sometimes (about 50% of the time) in mirrored mode instead of joined displays. The other times it just reconnects in joined mode.

The problem does not occur on a HDMI screen connected via usbc > HDMI adapter.