4

I'm trying to execute a script whenever a monitor or speaker is plugged in or not. I am ideally looking for a solution that would cover both monitors and speakers (so not something display-specific like xrandr), would not involve polling, and would handle multiple monitors and speakers.

I've read suggestions to try udevadm monitor --property to listen for events, however when I tried this and plugged the monitor in and out, nothing happened. The monitor is being connected through an HDMI port. (I've read some other solutions, but they seem to only apply to VGA?)

I've also read about sysfs, but haven't been able to figure out how to find all the devices connected through the HDMI ports and the sound ports. Looking around the sys folder, it's not at all obvious what devices all the folders correspond to. If you have any advice or links to tutorials on that, also appreciated!

Edit: I've noticed a lot of websites suggesting using something like /sys/class/drm/card0-HDMI-A-1/status to check if the device is plugged in, but my computer doesn't have a drm folder in /sys/class, thoughts?

jww
  • 97,681
  • 90
  • 411
  • 885
quantka
  • 920
  • 1
  • 10
  • 15
  • Possible duplicate of [Listen for harware change events from the linux kernel or udev](https://stackoverflow.com/q/3255174/608639). – jww Jun 29 '18 at 04:12

0 Answers0