断开连接的显示器仍报告为已连接

断开连接的显示器仍报告为已连接

我做了什么:

  1. 通过 HDMI 连接显示器。的输出xrandr符合预期:

    Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 32767 x 32767
    eDP1 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 310mm x 170mm
       1920x1080     60.01*+
       1400x1050     59.98  
       1600x900      60.00  
       1280x1024     60.02  
       1280x960      60.00  
       1368x768      60.00  
       1280x720      60.00  
       1024x768      60.00  
       1024x576      60.00  
       960x540       60.00  
       800x600       60.32    56.25  
       864x486       60.00  
       640x480       59.94  
       720x405       60.00  
       640x360       60.00  
    DP1 disconnected (normal left inverted right x axis y axis)
    DP2 disconnected (normal left inverted right x axis y axis)
    HDMI1 disconnected (normal left inverted right x axis y axis)
    HDMI2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 530mm x 300mm
       1920x1080     60.00*+  50.00    59.94  
       1680x1050     59.88  
       1600x900      60.00  
       1280x1024     75.02    60.02  
       1440x900      59.90  
       1280x800      59.91  
       1152x864      75.00  
       1280x720      60.00    50.00    59.94  
       1024x768      75.03    70.07    60.00  
       832x624       74.55  
       800x600       72.19    75.00    60.32    56.25  
       720x576       50.00  
       720x480       60.00    59.94  
       640x480       75.00    72.81    66.67    60.00    59.94  
       720x400       70.08  
    VIRTUAL1 disconnected (normal left inverted right x axis y axis)
    

    与连接的监视器相对应的文件/sys/class/drm/card0-HDMI-A-2/status包含单词connected(如预期)。

  2. 然后我断开 HDMI 电缆。当我检查/sys/class/drm/card0-HDMI-A-2/status它仍然包含connected.

  3. 当我现在xrandr再次运行时,它会以某种方式重置我的设置,并且文件会更新以反映正确的状态,即disconnected.

我的问题:如何修复该行为,以便 /sys 文件系统在拔掉电缆后立即正确反映状态?而且我不必打电话xrandr来启动更新。

替代问题:正在xrandr做什么导致 /sys 文件系统更新?这样我也许可以编写一个定期导致更新的小脚本。

在此期间我还查看了udevadm monitor

    monitor will print the received events for:
    UDEV - the event which udev sends out after rule processing
    KERNEL - the kernel uevent

    KERNEL[7260.824844] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
    UDEV  [7260.825690] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
    KERNEL[7280.130646] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
    UDEV  [7280.138375] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)

将 HDMI 电缆插入计算机后,前两行立即出现,但最后两行仅在我运行xrandr步骤 3 中提到的命令时出现。

如果有任何帮助的话,这是我的内核版本:

Linux archy 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64 GNU/Linux

相关内容