You are not logged in.

#1 2016-11-30 16:22:26

beardedlinuxgeek
Member
Registered: 2012-09-17
Posts: 32
Website

udev not detecting monitor unplug event

Starting with the monitor unplugged:

$ cat /sys/class/drm/card0-HDMI-A-2/status
disconnected

Plug the monitor in:

$ cat /sys/class/drm/card0-HDMI-A-2/status
connected

Unplug the monitor:

$ cat /sys/class/drm/card0-HDMI-A-2/status
connected

Here is the udev event log:

# Monitor starts off unplugged
$ udevadm monitor --environment --udev
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

# Monitor is plugged in
UDEV  [1952.080961] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=2926
SUBSYSTEM=drm
TAGS=:seat:uaccess:master-of-seat:
USEC_INITIALIZED=13401114

# Monitor is unplgged

Now, we're a state where the monitor is unplugged but it is saying it is connected and the udev event log doesn't show anything. But if I interact with the monitor by opening the display manager in my DE, or even just running xrandr (with no arguments), then the udev event is triggered and everything goes back to normal.

Is there anything I can do about this?

Last edited by beardedlinuxgeek (2016-11-30 16:23:27)

Offline

#2 2016-12-24 13:27:53

llevi
Member
Registered: 2016-12-24
Posts: 1

Re: udev not detecting monitor unplug event

Hi!
I have exactly the same problem.
With disabled nVidia card, only using the integrated intel graphics on an optimus-ready notebook.

Last edited by llevi (2016-12-24 13:29:52)

Offline

#3 2017-01-11 04:03:59

fasolt
Member
From: Australia
Registered: 2013-04-07
Posts: 6

Re: udev not detecting monitor unplug event

Hi, I'm having the same problem, with udev recognizing the HDMI cable when it is plugged it, but failing to notice when it is unplugged. I'm having the same output from udevadm monitor. Like the OP, if I run xrandr without arguments, it triggers the udev event. Running on a Sony Vaio Pro 13 laptop.
For full context:

/etc/udev/rules.d/10-hdmi-hotplug.rules wrote:

ACTION=="change", SUBSYSTEM=="drm", ENV{SYSTEMD_WANTS}=="hdmi_hotplug.service"

/etc/systemd/system/hdmi_hotplug.service wrote:

[Unit]
Description=udev HDMI Hotplug

[Service]
Type=oneshot
ExecStart=/usr/local/bin/hdmitoggle
RemainAfterExit=yes

/usr/local/bin/hdmitoggle wrote:

#!/bin/bash
#

export DISPLAY=:0
export XAUTHORITY=/home/fasolt/.Xauthority

if [[ "`cat /sys/class/drm/card0-HDMI-A-1/status`" == "connected" ]]
then
    xrandr --output HDMI1 --mode 1920x1080
    ln -sf /home/fasolt/.config/asoundrc_hdmi /home/fasolt/.asoundrc
else
    xrandr --output HDMI1 --off
    ln -sf /home/fasolt/.config/asoundrc_base /home/fasolt/.asoundrc
fi

The hdmitoggle script works like a charm when I run it manually, so there's no problem there. Changing the udev rule from a systemd service to RUN+="/usr/local/bin/hdmitoggle" doesn't change anything.

I'd greatly appreciate any help anyone could offer.

Edit: One thing I can add which may be significant, although well beyond my understanding, is that when running Elementary OS or Ubuntu on this machine by LiveUSB, udevadm monitor does observe the HDMI cable being unplugged, whereas running a Manjaro LiveUSB has the same result as in Arch (detects plugging in, but not unplugging). Since Manjaro is Arch-based, I'm not sure whether this is of any relevance, but thought it best to mention all the same.

Last edited by fasolt (2017-01-11 05:52:39)

Offline

#4 2017-02-08 01:24:09

WinEunuuchs2Unix
Member
Registered: 2017-02-08
Posts: 1

Re: udev not detecting monitor unplug event

This was working for me in November 2016 but is now broken on February 7, 2017 under Kernel 4.9.8.

This is a potential duplicate previously reported here in Arch by other people: https://bbs.archlinux.org/viewtopic.php?id=192746

Last edited by WinEunuuchs2Unix (2017-02-08 01:25:02)

Offline

#5 2019-02-14 06:04:28

Hacksign
Member
Registered: 2012-07-30
Posts: 131

Re: udev not detecting monitor unplug event

Same problem.
And I've post a 'bug' on kernel's bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=202579

Offline

#6 2019-03-13 20:51:06

Tumyfir
Member
Registered: 2019-03-13
Posts: 4

Re: udev not detecting monitor unplug event

Same problem here since i installed arch last year, it worked well on Ubuntu previously.
I'm on an Optimus laptop with nvidia card disabled.

Offline

#7 2019-12-07 17:48:13

Tumyfir
Member
Registered: 2019-03-13
Posts: 4

Re: udev not detecting monitor unplug event

the problem has disappeared for me since updating to kernel to 5.4

Offline

Board footer

Powered by FluxBB