5

I have an external monitor attached to my laptop HDMI port. When I boot my laptop, both the laptop screen and Monitor successfully turns on and works perfectly. However, whenever I unplug the external monitor, and then plug it back in, Ubuntu fails to detect that the monitor is plugged in again, and shows it as disconnected. The only way to get the external monitor to turn on again, is to reboot my laptop.

Laptop specs: Dell Inspiron 15 Gaming Nvidia GeForce GTX 960M

Output of lshw Display section:

       *-display
            description: 3D controller
            product: GM107M [GeForce GTX 960M]
            vendor: NVIDIA Corporation
            physical id: 0
            bus info: pci@0000:01:00.0
            version: a2
            width: 64 bits
            clock: 33MHz
            capabilities: pm msi pciexpress bus_master cap_list rom
            configuration: driver=nvidia latency=0
            resources: irq:130 memory:e2000000-e2ffffff memory:d0000000-dfffffff memory:e0000000-e1ffffff ioport:e000(size=128) memory:e3000000-e307ffff

Here is my xrandr output when both screens are attached:

Screen 0: minimum 8 x 8, current 3840 x 1113, maximum 16384 x 16384
eDP-1-1 connected primary 1920x1080+0+33 344mm x 193mm
   1920x1080     60.00*+  59.93    48.00  
   1680x1050     59.95    59.88  
   1600x1024     60.17  
   1400x1050     59.98  
   1280x1024     60.02  
   1440x900      59.89  
   1280x960      60.00  
   1360x768      59.80    59.96  
   1152x864      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   960x600       60.00  
   960x540       59.99  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   800x512       60.17  
   700x525       59.98  
   640x512       60.02  
   720x450       59.89  
   640x480       60.00    59.94  
   680x384       59.80    59.96  
   576x432       60.06  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DP-1-1 connected 1920x1080+1920+0 510mm x 290mm
   1920x1080     60.00*+
   1680x1050     59.88  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   832x624       74.55  
   800x600       75.00    60.32    56.25  
   640x480       75.00    59.94  
   720x400       70.08  
HDMI-1-1 disconnected

After unplugging and plugging back in, DP-1-1 shows up as disconnected.

Also, xrandr --auto does not turn the screen back on. Also tried restarting lightdm and unity but to no avail.

I have tried with the following display drivers, and none solves the problem:

  • noveau open source driver
  • nvidia-375.26 (recommended by nvidia)

Note that in Windows 10, the monitor is redetected when after the unplug, plug in cycle so this should not be an issue with the motherboard.

I need to unplug my screen a lot as I have to go to meetings etc and use my laptop there. Basically, the above issue is causing me to reboot my laptop up to 5 times a day. Please help!

Note this is not the same as Second Monitor Not Detected After HDMI unplugged and plugged back in

1

The closest I could find to your problem is this thread (ubuntuforums.org - Nvidia GTX 950 and TV not seeing signal after input change or power off/on) which references solutions for nVidia 970/980. It would seem your 960 is in between.

The solution proposed there is to reset the monitor to a bad mode and then a good mode using this code:

#!/bin/sh
#Fix TV state when HDMI link is lost.
#By Mario Limonciello <email address hidden>
sleep 10
OUTPUT="HDMI-0"
BAD_MODE="1280x720"
GOOD_MODE="1920x1080"

for MODE in $BAD_MODE $GOOD_MODE; do
DISPLAY=:0 xrandr --output $OUTPUT --mode $MODE
sleep 2
done

I think this script can be improved but wanted to post it in it's original incarnation.


One of the authors in the link wanted to setup udev to automatically call the script on hot-plug event. I've done this for HDMI with this code (hotplugtv) in the past to fix Ubuntu 16.04 pulseaudio 8 bug:

#!/bin/bash

if [[ $(cat /sys/class/drm/card*-HDMI-A-1/status | grep -Ec "^connected") -eq 1 ]]; then
        /bin/sleep 2;
        export PULSE_RUNTIME_PATH="/run/user/1000/pulse/";
        sudo -u rick -E pacmd set-card-profile 0 output:hdmi-stereo;
else
        export PULSE_RUNTIME_PATH="/run/user/1000/pulse/";
        sudo -u rick -E pacmd set-card-profile 0 output:analog-stereo;
fi

exit 0

You will need to modify the if test with your /sys/class/drm/... directory. Then modify the true side of the if test with your script file that resets hdmi screen. On the false side of the if test simply replace the code with a : (noop) if there is nothing to do when the hdmi device is unplugged.

In order to call this scrip from udev during hot-plug events create the file /etc/udev/rules.d/99-hotplugtv.rules containing:

ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/path/to/hotplugtv"

Change /path/to/ to the path where you placed hotplugtv script.

  • Thank you so much for your efforts. I've tried the script quickly for DP-1-1 but unfortunately get the output: cannot find mode 1280x720 xrandr: cannot find mode 1920x1080. The display then remains disconnected. I think this is due to xrandr not showing any resolutions for this display when xrandr (without any parameters) is invoked. Ill be going through the posted thread though looking for a solution. Thanks for the tip on looking at /sys/class/drm... for the monitor status! I see there are other files in that directory as well, will do some research and experiment here. – mdewit Jan 27 '17 at 8:48
  • You are welcome. Sorry to hear their solution didn't help you but glad to hear you have some leads to follow up on. – WinEunuuchs2Unix Jan 27 '17 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.