No HDMI events on udev


I’ve been trying to create a udev rule that triggers when i plug or unplug an HDMI monitor; I tried looking at udevadm monitor output to figure out the characteristics of the udev event that should trigger when I plug/unplug the HDMI cable, but had no output, which seemed strange.
I tried the same command on a Linux Mint live-USB that I had lying around, and this time got events for plugging in and out, so it doesn’t seem to be an issue with my hardware.
This is my system info:

$ inxi -Fxxxz
  Kernel: 6.0.15-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    Desktop: Xfce v: 4.18.0 tk: Gtk v: 3.24.35 info: xfce4-panel wm: xfwm
    v: 4.18.0 vt: 7 dm: LightDM v: 1.32.0 Distro: Manjaro Linux
    base: Arch Linux
  Type: Laptop System: HP product: Victus by HP Gaming Laptop 15-fa0xxx v: N/A
    serial: <filter> Chassis: type: 10 serial: <filter>
  Mobo: HP model: 8A50 v: 37.43 serial: <filter> UEFI: AMI v: F.10
    date: 08/23/2022
  ID-1: BAT0 charge: 36.0 Wh (69.8%) condition: 51.6/52.6 Wh (98.2%)
    volts: 11.7 min: 11.6 model: HP Primary type: Li-ion serial: <filter>
    status: discharging cycles: 10
  Info: 8-core (4-mt/4-st) model: 12th Gen Intel Core i5-12450H bits: 64
    type: MST AMCP smt: enabled arch: Alder Lake rev: 3 cache: L1: 704 KiB
    L2: 7 MiB L3: 12 MiB
  Speed (MHz): avg: 2500 min/max: 400/4400:3300 volts: 1.2 V
    ext-clock: 100 MHz cores: 1: 2500 2: 2500 3: 2500 4: 2500 5: 2500 6: 2500
    7: 2500 8: 2500 9: 2500 10: 2500 11: 2500 12: 2500 bogomips: 59916
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Device-1: Intel Alder Lake-P GT1 [UHD Graphics] vendor: Hewlett-Packard
    driver: i915 v: kernel arch: Gen-12.2 ports: active: eDP-1
    empty: DP-1, DP-2, DP-3, DP-4 bus-ID: 00:02.0 chip-ID: 8086:46a3
    class-ID: 0300
  Device-2: NVIDIA TU117M [GeForce GTX 1650 Mobile / Max-Q]
    vendor: Hewlett-Packard driver: nvidia v: 525.60.11 arch: Turing pcie:
    speed: 2.5 GT/s lanes: 8 bus-ID: 01:00.0 chip-ID: 10de:1f9d class-ID: 0300
  Device-3: Chicony HP Wide Vision HD Camera type: USB driver: uvcvideo
    bus-ID: 3-6:2 chip-ID: 04f2:b766 class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 21.1.6 compositor: xfwm v: 4.18.0 driver: X:
    loaded: modesetting,nvidia alternate: fbdev,nouveau,nv,vesa dri: iris
    gpu: i915 display-ID: :0.0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
    s-diag: 582mm (22.93")
  Monitor-1: eDP-1 model: ChiMei InnoLux 0x1521 res: 1920x1080 hz: 144
    dpi: 142 size: 344x193mm (13.54x7.6") diag: 394mm (15.5") modes: 1920x1080
  API: OpenGL v: 4.6 Mesa 22.3.1 renderer: Mesa Intel Graphics (ADL GT2)
    direct render: Yes
  Device-1: Intel Alder Lake PCH-P High Definition Audio
    vendor: Hewlett-Packard driver: sof-audio-pci-intel-tgl bus-ID: 00:1f.3
    chip-ID: 8086:51c8 class-ID: 0401
  Device-2: NVIDIA vendor: Hewlett-Packard driver: snd_hda_intel v: kernel
    pcie: speed: 2.5 GT/s lanes: 8 bus-ID: 01:00.1 chip-ID: 10de:10fa
    class-ID: 0403
  Sound API: ALSA v: k6.0.15-1-MANJARO running: yes
  Sound Server-1: JACK v: 1.9.21 running: no
  Sound Server-2: PulseAudio v: 16.1 running: yes
  Sound Server-3: PipeWire v: 0.3.63 running: yes
  Device-1: MEDIATEK MT7921 802.11ax PCI Express Wireless Network Adapter
    vendor: AzureWave driver: mt7921e v: kernel pcie: speed: 5 GT/s lanes: 1
    bus-ID: 04:00.0 chip-ID: 14c3:7961 class-ID: 0280
  IF: wlp4s0 state: up mac: <filter>
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Hewlett-Packard driver: r8169 v: kernel pcie: speed: 2.5 GT/s
    lanes: 1 port: 3000 bus-ID: 05:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: eno1 state: down mac: <filter>
  Device-1: IMC Networks Wireless_Device type: USB driver: btusb v: 0.8
    bus-ID: 3-7:3 chip-ID: 13d3:3567 class-ID: e001 serial: <filter>
  Report: bt-adapter ID: hci0 rfk-id: 0 state: up address: <filter>
  Local Storage: total: 476.94 GiB used: 368.77 GiB (77.3%)
  ID-1: /dev/nvme0n1 vendor: Micron model: MTFDKBA512TFH-1BC1AABHA
    size: 476.94 GiB speed: 63.2 Gb/s lanes: 4 type: SSD serial: <filter>
    rev: HPS0043 temp: 35.9 C scheme: GPT
  ID-1: / size: 467.89 GiB used: 368.77 GiB (78.8%) fs: ext4
    dev: /dev/nvme0n1p6
  ID-2: /boot/efi size: 509 MiB used: 316 KiB (0.1%) fs: vfat
    dev: /dev/nvme0n1p5
  Alert: No swap data was found.
  System Temperatures: cpu: 31.0 C mobo: N/A
  Fan Speeds (RPM): cpu: 2209 fan-2: 1996
  Processes: 264 Uptime: 1h 9m wakeups: 7387 Memory: 15.3 GiB
  used: 2.51 GiB (16.4%) Init: systemd v: 252 default: graphical Compilers:
  gcc: 12.2.0 clang: 14.0.6 Packages: 1250 pm: pacman pkgs: 1235 pm: flatpak
  pkgs: 15 Shell: Bash (su) v: 5.1.16 running-in: xfce4-terminal inxi: 3.3.24
$ mhwd -li
> Installed PCI configs:
                  NAME               VERSION          FREEDRIVER           TYPE
video-hybrid-intel-nvidia-prime            2021.11.04               false            PCI
     video-modesetting            2020.01.13                true            PCI

Warning: No installed USB configs!

My problem is very similar to the one found on this forum post Plug/unplug event for external monitor is not detected by udev

Is there maybe a program different to udev that could be used to listen in on these events, and execute a command accordingly; or a config file that could be causing this issue?


Maybe have look at the config:

cat /var/lib/mhwd/db/pci/graphic_drivers/hybrid-intel-nvidia-prime/MHWDCONFIG 

Probably options nvidia "NVreg_DynamicPowerManagement=0x02" has something to do with this behavior while on Linux Mint it is not set?
Chapter 22. PCI-Express Runtime D3 (RTD3) Power Management


I’ve tried to fiddle around with the nvidia kernel modules; in /var/lib/mhwd/db/pci/graphic_drivers/hybrid-intel-nvidia-prime/MHWDCONFIG, as well as /etc/modprobe.d/mhwd-gpu.conf, by changing NVreg_DynamicPowerManagement=0x02 for NVreg_DynamicPowerManagement=0x01, but this doesn’t seem to have any effect on the nvidia module parameters. In fact, the nvidia module doesn’t seem to have any loaded parameters at all.

$systool -vm nvidia
Module = "nvidia"

    coresize            = "61218816"
    initsize            = "0"
    initstate           = "live"
    refcnt              = "99"
    srcversion          = "E6E92E3273CC30C56A44147"
    taint               = "POE"
    uevent              = <store method only>
    version             = "525.60.11"

    .altinstr_aux       = "0xffffffffc12daa54"
    .altinstr_replacement= "0xffffffffc12da9f6"
    .altinstructions    = "0xffffffffc12dc418"
    .bss                = "0xffffffffc3fcdcc0"
    .data.once          = "0xffffffffc3fcd828"
    .data               = "0xffffffffc3f15460"          = "0xffffffffc3fcd820"
    .exit.text          = "0xffffffffc12db9c2"
    .gnu.linkonce.this_module= "0xffffffffc3fcd900"
    .ibt_endbr_seal     = "0xffffffffc3a5f747"          = "0xffffffffc4210000"
    .init.text          = "0xffffffffc420f000"
    .note.Linux         = "0xffffffffc12dc024"  = "0xffffffffc12dc000"
    .orc_unwind         = "0xffffffffc3a5fdd3"
    .orc_unwind_ip      = "0xffffffffc3d32053"
    .parainstructions   = "0xffffffffc3a35a48"
    .printk_index       = "0xffffffffc3fcd660"
    .retpoline_sites    = "0xffffffffc3a36c13"
    .return_sites       = "0xffffffffc3a5eb7f"
    .rodata             = "0xffffffffc12dc600"
    .rodata.cst2        = "0xffffffffc3a36268"
    .rodata.str1.1      = "0xffffffffc3a34b6d"
    .rodata.str1.8      = "0xffffffffc39f54d8"
    .smp_locks          = "0xffffffffc3a359c4"
    .static_call_sites  = "0xffffffffc3fcd829"
    .strtab             = "0xffffffffc43227e0"
    .symtab             = "0xffffffffc4211000"
    .text               = "0xffffffffc07ac000"
    .text.unlikely      = "0xffffffffc12daac0"
    __bug_table         = "0xffffffffc3f15000"
    __jump_table        = "0xffffffffc3f14000"
    __ksymtab           = "0xffffffffc12dc054"
    __ksymtab_strings   = "0xffffffffc3a3626c"
    __mcount_loc        = "0xffffffffc39f401e"
    __param             = "0xffffffffc3a35c28"

The output of systool -vm nvidia also remains static when i use modprobe nvidia "NVreg_DynamicPowerManagement=0x01" or modprobe nvidia "NVreg_DynamicPowerManagement=0x02"

My /etc/modprobe.d/mhwd-gpu.conf, just in case:

$cat /etc/modprobe.d/mhwd-gpu.conf 
## Generated by mhwd - Manjaro Hardware Detection
blacklist nouveau
blacklist ttm
blacklist drm_kms_helper
blacklist drm
options nvidia NVreg_DynamicPowerManagement=0x01


Nevermind, I can see the nvidia module parameters; just not with systool -vm nvidia. Still, changing NVreg_DynamicPowerManagement to other values didn’t solve my problem.

$cat /proc/driver/nvidia/params
ResmanDebugLevel: 4294967295
RmLogonRC: 1
ModifyDeviceFiles: 1
DeviceFileUID: 0
DeviceFileGID: 0
DeviceFileMode: 438
InitializeSystemMemoryAllocations: 1
UsePageAttributeTable: 4294967295
EnableMSI: 1
EnablePCIeGen3: 0
MemoryPoolSize: 0
KMallocHeapMaxSize: 0
VMallocHeapMaxSize: 0
IgnoreMMIOCheck: 0
TCEBypassMode: 0
EnableStreamMemOPs: 0
EnableUserNUMAManagement: 1
NvLinkDisable: 0
RmProfilingAdminOnly: 1
PreserveVideoMemoryAllocations: 0
EnableS0ixPowerManagement: 0
S0ixPowerManagementVideoMemoryThreshold: 256
DynamicPowerManagement: 2
DynamicPowerManagementVideoMemoryThreshold: 200
RegisterPCIDriver: 1
EnablePCIERelaxedOrderingMode: 0
EnableGpuFirmware: 18
EnableGpuFirmwareLogs: 2
EnableDbgBreakpoint: 0
OpenRmEnableUnsupportedGpus: 0
DmaRemapPeerMmio: 1
RegistryDwords: ""
RegistryDwordsPerDevice: ""
RmMsg: ""
GpuBlacklist: ""
TemporaryFilePath: ""
ExcludedGpus: ""