Plug/unplug event for external monitor is not detected by udev

I’m using Manjaro i3 on a Legion laptop with switchable graphics (AMD/nVidia) and I’m trying to get the display to automatically change to an external monitor whenever I connect it.

I already know how to use xrandr to do this manually, so now I’m trying to get the script that I wrote to be run automatically whenever a HDMI connection occurs. According to the documentation on xrandr - ArchWiki I’d need to use udev to detect the HDMI connection event, however when I run the command udevadm monitor there is no event registered when I plug or unplug the external monitor through HDMI, so I can’t progress any further to identify the device to write a rule, and I also wouldn’t expect it to work anyway since the event is not detected…

Does anybody know what could be going on?

These are my machine’s specs (from the inxi command):

System:
  Kernel: 5.15.41-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.1.0
    Desktop: i3 v: 4.20.1 info: i3bar vt: 7 dm: LightDM v: 1.30.0
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 82B1 v: Lenovo Legion 5 15ARH05H
    serial: <superuser required> Chassis: type: 10 v: Lenovo Legion 5 15ARH05H
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0J40700 WIN
    serial: <superuser required> UEFI: LENOVO v: FSCN14WW date: 08/26/2020
Battery:
  ID-1: BAT0 charge: 25.0 Wh (45.0%) condition: 55.6/60.0 Wh (92.7%)
    volts: 15.2 min: 15.4 model: SMP L19M4PC0 type: Li-poly serial: <filter>
    status: discharging cycles: 58
Memory:
  RAM: total: 7.2 GiB used: 1.16 GiB (16.1%)
  RAM Report:
    permissions: Unable to run dmidecode. Root privileges required.
CPU:
  Info: 6-core model: AMD Ryzen 5 4600H with Radeon Graphics bits: 64
    type: MT MCP smt: enabled arch: Zen 2 rev: 1 cache: L1: 384 KiB L2: 3 MiB
    L3: 8 MiB
  Speed (MHz): avg: 1439 high: 1580 min/max: 1400/3000 boost: enabled
    cores: 1: 1566 2: 1397 3: 1397 4: 1396 5: 1397 6: 1397 7: 1397 8: 1526
    9: 1580 10: 1397 11: 1432 12: 1397 bogomips: 71893
  Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1
    bmi2 bpext cat_l3 cdp_l3 clflush clflushopt clwb clzero cmov cmp_legacy
    constant_tsc cpb cpuid cqm cqm_llc cqm_mbm_local cqm_mbm_total
    cqm_occup_llc cr8_legacy cx16 cx8 de decodeassists extapic extd_apicid
    f16c flushbyasid fma fpu fsgsbase fxsr fxsr_opt ht hw_pstate ibpb ibrs
    ibs irperf lahf_lm lbrv lm mba mca mce misalignsse mmx mmxext monitor
    movbe msr mtrr mwaitx nonstop_tsc nopl npt nrip_save nx osvw
    overflow_recov pae pat pausefilter pclmulqdq pdpe1gb perfctr_core
    perfctr_llc perfctr_nb pfthreshold pge pni popcnt pse pse36 rapl rdpid
    rdpru rdrand rdseed rdt_a rdtscp rep_good sep sha_ni skinit smap smca
    smep ssbd sse sse2 sse4_1 sse4_2 sse4a ssse3 stibp succor svm svm_lock
    syscall tce topoext tsc tsc_scale umip v_spec_ctrl v_vmsave_vmload vgif
    vmcb_clean vme vmmcall wbnoinvd wdt xgetbv1 xsave xsavec xsaveerptr
    xsaveopt xsaves
Graphics:
  Device-1: AMD Renoir vendor: Lenovo driver: amdgpu v: kernel pcie:
    speed: 16 GT/s lanes: 16 ports: active: eDP-1 empty: none bus-ID: 05:00.0
    chip-ID: 1002:1636 class-ID: 0300
  Device-2: Syntek Integrated Camera type: USB driver: uvcvideo
    bus-ID: 3-3:2 chip-ID: 174f:244c class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 21.1.3 compositor: Picom v: git-7e568
    driver: X: loaded: amdgpu unloaded: modesetting alternate: fbdev,vesa
    gpu: amdgpu display-ID: :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 mapped: eDP model: BOE Display 0x08e8 res: 1920x1080
    hz: 120 dpi: 142 size: 344x194mm (13.54x7.64") diag: 395mm (15.5") modes:
    max: 1920x1080 min: 640x480
  Message: Unable to show GL data. Required tool glxinfo missing.
Audio:
  Device-1: AMD ACP/ACP3X/ACP6x Audio Coprocessor vendor: Lenovo driver: N/A
    pcie: speed: 16 GT/s lanes: 16 bus-ID: 05:00.5 chip-ID: 1022:15e2
    class-ID: 0480
  Device-2: AMD Family 17h/19h HD Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel pcie: speed: 16 GT/s lanes: 16
    bus-ID: 05:00.6 chip-ID: 1022:15e3 class-ID: 0403
  Sound Server-1: ALSA v: k5.15.41-1-MANJARO running: yes
  Sound Server-2: JACK v: 1.9.21 running: no
  Sound Server-3: PulseAudio v: 15.0 running: no
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Lenovo driver: r8169 v: kernel pcie: speed: 2.5 GT/s lanes: 1
    port: 2000 bus-ID: 03:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: eno1 state: down mac: <filter>
  Device-2: Intel Wi-Fi 6 AX200 driver: iwlwifi v: kernel pcie:
    speed: 5 GT/s lanes: 1 bus-ID: 04:00.0 chip-ID: 8086:2723 class-ID: 0280
  IF: wlp4s0 state: up mac: <filter>
  IP v4: <filter> type: dynamic noprefixroute scope: global
    broadcast: <filter>
  IP v6: <filter> type: dynamic noprefixroute scope: global
  IP v6: <filter> type: noprefixroute scope: link
  WAN IP: <filter>
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8
    bus-ID: 5-3:3 chip-ID: 8087:0029 class-ID: e001
  Report: rfkill ID: hci0 rfk-id: 3 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: see --recommends
Logical:
  Message: No logical block device data found.
RAID:
  Message: No RAID data found.
Drives:
  Local Storage: total: 476.94 GiB used: 23.96 GiB (5.0%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: MZALQ512HALU-000L2
    size: 476.94 GiB speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
    rev: AL2QFXV7 temp: 27.9 C scheme: GPT
  Message: No optical or floppy data found.
Partition:
  ID-1: / size: 232.8 GiB used: 23.93 GiB (10.3%) fs: ext4
    dev: /dev/nvme0n1p5 label: N/A uuid: 1c8dea05-11d0-40ed-a6df-3dd99f8ec94e
  ID-2: /boot/efi size: 256 MiB used: 32.9 MiB (12.9%) fs: vfat
    dev: /dev/nvme0n1p1 label: SYSTEM_DRV uuid: A0A4-06E4
Swap:
  Alert: No swap data was found.
Unmounted:
  ID-1: /dev/nvme0n1p2 size: 16 MiB fs: <superuser required> label: N/A
    uuid: N/A
  ID-2: /dev/nvme0n1p3 size: 238.1 GiB fs: ntfs label: Windows-SSD
    uuid: BC14A4CE14A48CC8
  ID-3: /dev/nvme0n1p4 size: 1000 MiB fs: ntfs label: WINRE_DRV
    uuid: CE04A5F104A5DD29
USB:
  Hub-1: 3-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0
    speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
  Device-1: 3-3:2 info: Syntek Integrated Camera type: Video
    driver: uvcvideo interfaces: 2 rev: 2.0 speed: 480 Mb/s power: 500mA
    chip-ID: 174f:244c class-ID: 0e02 serial: <filter>
  Hub-2: 4-0:1 info: Super-speed hub ports: 2 rev: 3.1 speed: 10 Gb/s
    chip-ID: 1d6b:0003 class-ID: 0900
  Hub-3: 5-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0
    speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
  Hub-4: 5-1:2 info: Genesys Logic Hub ports: 2 rev: 2.1 speed: 480 Mb/s
    chip-ID: 05e3:0610 class-ID: 0900
  Device-1: 5-3:3 info: Intel AX200 Bluetooth type: Bluetooth driver: btusb
    interfaces: 2 rev: 2.0 speed: 12 Mb/s power: 100mA chip-ID: 8087:0029
    class-ID: e001
  Device-2: 5-4:4 info: Integrated Express ITE Device(8910) type: Keyboard
    driver: hid-generic,usbhid interfaces: 1 rev: 2.0 speed: 12 Mb/s
    power: 100mA chip-ID: 048d:c100 class-ID: 0301
  Hub-5: 6-0:1 info: Super-speed hub ports: 2 rev: 3.1 speed: 10 Gb/s
    chip-ID: 1d6b:0003 class-ID: 0900
  Hub-6: 6-1:2 info: Genesys Logic GL3523 Hub ports: 2 rev: 3.2
    speed: 5 Gb/s chip-ID: 05e3:0620 class-ID: 0900
Sensors:
  System Temperatures: cpu: N/A mobo: N/A gpu: amdgpu temp: 36.0 C
  Fan Speeds (RPM): N/A
Info:
  Processes: 244 Uptime: 36m wakeups: 1 Init: systemd v: 250 Compilers:
  gcc: 12.1.0 clang: 13.0.1 Packages: pacman: 1167 Shell: Bash v: 5.1.16
  running-in: urxvtd inxi: 3.3.16

And here is the output for mhwd -l && mhwd -li:

> 0000:03:00.0 (0200:10ec:8168) Network controller Realtek Semiconductor Co., Ltd.:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
         network-r8168            2016.04.20                true            PCI


> 0000:01:00.0 (0300:10de:1f15) Display controller nVidia Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
          video-nvidia            2021.11.04               false            PCI
    video-nvidia-470xx            2021.11.04               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI


> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-amd-nvidia-prime            2021.12.18               false            PCI
           video-linux            2018.05.04                true            PCI


Warning: No installed USB configs!

Hello, I am having the exact same issue. Did you find a solution, or any sources of information that might help solve the problem?

Thanks.