My udev
rule is not working. I've added information about the udev
rule:
udev rule:
$ cat /lib/udev/rules.d/95-monitor.rules
KERNEL=="card0", SUBSYSTEM=="drm", RUN+="/bin/bash /home/koko/Desktop/monitor.sh"
executed:
sudo udevadm control --reload
sudo udevadm trigger
monitor.sh
#!/bin/bash
notify-send "Monitor Connected."
Udev is running:
$ service --status-all
..
[ + ] udev
..
udev info
$ sudo udevadm info -a -p /devices/pci00:00/0000:00:02.0/drm/card0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:02.0/drm/card0':
KERNEL=="card0"
SUBSYSTEM=="drm"
DRIVER==""
ATTR{error}=="no error state collected"
looking at parent device '/devices/pci0000:00/0000:00:02.0':
KERNELS=="0000:00:02.0"
SUBSYSTEMS=="pci"
DRIVERS=="i915"
ATTRS{boot_vga}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x030000"
ATTRS{consistent_dma_mask_bits}=="36"
ATTRS{d3cold_allowed}=="1"
ATTRS{device}=="0x0046"
ATTRS{dma_mask_bits}=="36"
ATTRS{driver_override}=="(null)"
ATTRS{enable}=="1"
ATTRS{irq}=="26"
ATTRS{local_cpulist}=="0-3"
ATTRS{local_cpus}=="0f"
ATTRS{msi_bus}=="1"
ATTRS{numa_node}=="-1"
ATTRS{subsystem_device}=="0x0410"
ATTRS{subsystem_vendor}=="0x1028"
ATTRS{vendor}=="0x8086"
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
udevadm monitor:
$ sudo udevadm monitor --environment --udev
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
UDEV [26447.971745] change /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=3035
SUBSYSTEM=drm
TAGS=:uaccess:master-of-seat:seat:
USEC_INITIALIZED=21623159
RUN
(because the programs are started by the kernel as root in a restricted environment). I don't know in detail hownotify-send
works, but this may be the problem. Try appending to a file in/tmp
or a named pipe while insideRUN
instead, and useinotify
etc. if you want messages. If a udev rule needs to interact with the user, re-think your approach - it's probably wrong, that's not what the rules are for. – dirkt Aug 10 '17 at 12:25touch
ing a file in/tmp
, also didn't work. – Kinop Aug 10 '17 at 13:24