I am trying to get a script to run every time my HDMI monitor is plugged in and after doing some reading I found this and in it asks me to create 99-monitor-hotplug.rules and put it /etc/udev/rules.d and specify which script I want to run. The rule looks like this:
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/root/hotplug.sh"
Well I did that but the script does not run. I know this because in the script all I have is:
#!/bin/bash
opera
I made the script deliberately that simple so I can see something is happening. When I invoke the script from the command line, Opera does run.
Here is what what happens when I plug and unplug my HDMI monitor when "udevadm monitor --property" is running:
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[730.834194] change /devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 (drm)
ACTION=change
DEVNAME=/dev/dri/card1
DEVPATH=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
DEVTYPE=drm_minor
HOTPLUG=1
MAJOR=226
MINOR=1
SEQNUM=3245
SUBSYSTEM=drm
UDEV [730.835499] change /devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 (drm)
ACTION=change
DEVNAME=/dev/dri/card1
DEVPATH=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_01_00_0
ID_PATH=pci-0000:01:00.0
ID_PATH_TAG=pci-0000_01_00_0
MAJOR=226
MINOR=1
SEQNUM=3245
SUBSYSTEM=drm
TAGS=:seat:uaccess:master-of-seat:
USEC_INITIALIZED=3217504
KERNEL[738.204082] change /devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 (drm)
ACTION=change
DEVNAME=/dev/dri/card1
DEVPATH=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
DEVTYPE=drm_minor
HOTPLUG=1
MAJOR=226
MINOR=1
SEQNUM=3246
SUBSYSTEM=drm
UDEV [738.206107] change /devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 (drm)
ACTION=change
DEVNAME=/dev/dri/card1
DEVPATH=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_01_00_0
ID_PATH=pci-0000:01:00.0
ID_PATH_TAG=pci-0000_01_00_0
MAJOR=226
MINOR=1
SEQNUM=3246
SUBSYSTEM=drm
TAGS=:seat:uaccess:master-of-seat:
USEC_INITIALIZED=3217504
Once the rule was added, I did run: sudo udevadm control --reload-rules
Can someone assist please? I have a feeling the rule might be incorrect and I am new to creating udev rules. I am running Ubuntu 16.04.
disown
it. – user.dz Jun 24 '16 at 14:52