Trigger event when connecting / disconnecting an HDMI monitor? What about the speakers? (Ubunt)

I try to execute a script whenever a monitor or speaker is connected or not. I am ideally looking for a solution that will cover both monitors and speakers (and not something specific, for example, xrandr), will not include polling and will process several monitors and speakers.

I read the suggestions to try udevadm monitor --property to listen for events, however, when I tried this and connected the monitor to the input and output, nothing happened. The monitor is connected via the HDMI port. (I read some other solutions, but they seem to only apply to VGA?)

I also read about sysfs , but couldn't figure out how to find all devices connected via HDMI and audio ports. Looking back at the sys folder, it is not at all obvious which devices correspond to all folders. If you have any tips or links to tutorials on this subject, also rate it!

Edit: I noticed a lot of websites suggesting using something like /sys/class/drm/card0-HDMI-A-1/status to check if the device is connected, but there is no drm folder in / sys / on my computer class, thoughts?

+4
source share

Source: https://habr.com/ru/post/1483433/


All Articles