4

I'd like my computer to run certain scripts when a specific keyboard is (1) plugged in, (2) plugged out, (3) detected at startup.

Here's the device:

[rob@X200 vim]$ lsusb | grep keyb
Bus 005 Device 012: ID 04d9:1400 Holtek Semiconductor, Inc. PS/2 keyboard + mouse controller

and here's the .rules file:

[rob@X200 rules.d]$ cat 080-model-m.rules 
ACTION=="add", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="1400", RUN+="/home/rob/home/scripts/caps-equals-super.sh"

ACTION=="remove", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="1400", RUN+="/home/rob/home/scripts/revert-keyboard-to-default.sh"

The scripts have been tested to work, but are not triggered upon device plugin/plugout. I'm not quite sure how I'd go about having the script triggered if the keyboard is detected at startup, but I imagine I have to tell something (systemd, udev?) not to run the script until certain resources are ready.

Here's udevadm monitor -p on device plugin:

KERNEL[78150.293418] add      /devices/pci0000:00/0000:00:1d.0/usb5/5-1 (usb)
ACTION=add
BUSNUM=005
DEVNAME=/dev/bus/usb/005/014
DEVNUM=014
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1
DEVTYPE=usb_device
MAJOR=189
MINOR=525
PRODUCT=4d9/1400/143
SEQNUM=2260
SUBSYSTEM=usb
TYPE=0/0/0

KERNEL[78150.297188] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 (usb) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 DEVTYPE=usb_interface INTERFACE=3/1/1 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip01in00 PRODUCT=4d9/1400/143 SEQNUM=2261 SUBSYSTEM=usb TYPE=0/0/0

KERNEL[78150.315292] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025 (hid) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input0 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2262 SUBSYSTEM=hid

KERNEL[78150.315615] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44 (input) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44 EV=120013 KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe LED=7 MODALIAS=input:b0003v04D9p1400e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8C,8E,96,98,9E,9F,A1,A3,A4,A5,A6,AD,B0,B1,B2,B3,B4,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input0" PRODUCT=3/4d9/1400/110 PROP=0 SEQNUM=2263 SUBSYSTEM=input UNIQ=""

KERNEL[78150.315762] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44/event6 (input) ACTION=add DEVNAME=/dev/input/event6 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44/event6 MAJOR=13 MINOR=70 SEQNUM=2264 SUBSYSTEM=input

KERNEL[78150.315864] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/hidraw/hidraw0 (hidraw) ACTION=add DEVNAME=/dev/hidraw0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/hidraw/hidraw0 MAJOR=247 MINOR=0 SEQNUM=2265 SUBSYSTEM=hidraw

KERNEL[78150.315934] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 (usb) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 DEVTYPE=usb_interface INTERFACE=3/1/2 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip02in01 PRODUCT=4d9/1400/143 SEQNUM=2266 SUBSYSTEM=usb TYPE=0/0/0

KERNEL[78150.348378] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026 (hid) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input1 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2267 SUBSYSTEM=hid

KERNEL[78150.348750] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45 (input) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45 EV=17 KEY=1f0000 2000000 39fad941d001 1e000000000000 0 MODALIAS=input:b0003v04D9p1400e0110-e0,1,2,4,k71,72,73,74,80,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,AB,AC,AD,D9,110,111,112,113,114,r0,1,8,am4,lsfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input1" PRODUCT=3/4d9/1400/110 PROP=0 REL=103 SEQNUM=2268 SUBSYSTEM=input UNIQ=""

KERNEL[78150.348806] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/event7 (input) ACTION=add DEVNAME=/dev/input/event7 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/event7 MAJOR=13 MINOR=71 SEQNUM=2269 SUBSYSTEM=input

KERNEL[78150.349215] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/mouse0 (input) ACTION=add DEVNAME=/dev/input/mouse0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/mouse0 MAJOR=13 MINOR=32 SEQNUM=2270 SUBSYSTEM=input

KERNEL[78150.349570] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/hidraw/hidraw1 (hidraw) ACTION=add DEVNAME=/dev/hidraw1 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/hidraw/hidraw1 MAJOR=247 MINOR=1 SEQNUM=2271 SUBSYSTEM=hidraw

UDEV [78150.352414] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1 (usb) ACTION=add BUSNUM=005 DEVNAME=/dev/bus/usb/005/014 DEVNUM=014 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1 DEVTYPE=usb_device ID_BUS=usb ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_FROM_DATABASE=PS/2 keyboard + mouse controller ID_MODEL_ID=1400 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_USB_INTERFACES=:030101:030102: ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_FROM_DATABASE=Holtek Semiconductor, Inc. ID_VENDOR_ID=04d9 MAJOR=189 MINOR=525 PRODUCT=4d9/1400/143 SEQNUM=2260 SUBSYSTEM=usb TYPE=0/0/0 USEC_INITIALIZED=150293560

UDEV [78150.359452] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 (usb) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 DEVTYPE=usb_interface ID_MODEL_FROM_DATABASE=PS/2 keyboard + mouse controller ID_VENDOR_FROM_DATABASE=Holtek Semiconductor, Inc. INTERFACE=3/1/1 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip01in00 PRODUCT=4d9/1400/143 SEQNUM=2261 SUBSYSTEM=usb TYPE=0/0/0 USEC_INITIALIZED=297361

UDEV [78150.361013] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025 (hid) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input0 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2262 SUBSYSTEM=hid USEC_INITIALIZED=315394

UDEV [78150.363279] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44 (input) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44 EV=120013 ID_BUS=usb ID_FOR_SEAT=input-pci-0000_00_1d_0-usb-0_1_1_0 ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_KEYBOARD=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.0 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_0 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=00 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe LED=7 MODALIAS=input:b0003v04D9p1400e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8C,8E,96,98,9E,9F,A1,A3,A4,A5,A6,AD,B0,B1,B2,B3,B4,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input0" PRODUCT=3/4d9/1400/110 PROP=0 SEQNUM=2263 SUBSYSTEM=input TAGS=:seat: UNIQ="" USEC_INITIALIZED=315688

UDEV [78150.363612] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 (usb) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 DEVTYPE=usb_interface ID_MODEL_FROM_DATABASE=PS/2 keyboard + mouse controller ID_VENDOR_FROM_DATABASE=Holtek Semiconductor, Inc. INTERFACE=3/1/2 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip02in01 PRODUCT=4d9/1400/143 SEQNUM=2266 SUBSYSTEM=usb TYPE=0/0/0 USEC_INITIALIZED=150315976

UDEV [78150.366574] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/hidraw/hidraw0 (hidraw) ACTION=add DEVNAME=/dev/hidraw0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/hidraw/hidraw0 MAJOR=247 MINOR=0 SEQNUM=2265 SUBSYSTEM=hidraw USEC_INITIALIZED=150315900

UDEV [78150.367209] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026 (hid) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input1 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2267 SUBSYSTEM=hid USEC_INITIALIZED=348465

UDEV [78150.369365] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45 (input) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45 EV=17 ID_BUS=usb ID_FOR_SEAT=input-pci-0000_00_1d_0-usb-0_1_1_1 ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_MOUSE=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.1 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=01 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 KEY=1f0000 2000000 39fad941d001 1e000000000000 0 MODALIAS=input:b0003v04D9p1400e0110-e0,1,2,4,k71,72,73,74,80,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,AB,AC,AD,D9,110,111,112,113,114,r0,1,8,am4,lsfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input1" PRODUCT=3/4d9/1400/110 PROP=0 REL=103 SEQNUM=2268 SUBSYSTEM=input TAGS=:seat: UNIQ="" USEC_INITIALIZED=349029

UDEV [78150.370966] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/hidraw/hidraw1 (hidraw) ACTION=add DEVNAME=/dev/hidraw1 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/hidraw/hidraw1 MAJOR=247 MINOR=1 SEQNUM=2271 SUBSYSTEM=hidraw USEC_INITIALIZED=349776

UDEV [78150.372975] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/event7 (input) ACTION=add DEVLINKS=/dev/input/by-id/usb-04d9_1400-if01-event-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.1-event-mouse DEVNAME=/dev/input/event7 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/event7 ID_BUS=usb ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_MOUSE=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.1 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=01 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 MAJOR=13 MINOR=71 SEQNUM=2269 SUBSYSTEM=input USEC_INITIALIZED=349103

UDEV [78150.373507] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44/event6 (input) ACTION=add DEVLINKS=/dev/input/by-id/usb-04d9_1400-event-kbd /dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.0-event-kbd DEVNAME=/dev/input/event6 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0025/input/input44/event6 ID_BUS=usb ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_KEYBOARD=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.0 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_0 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=00 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 MAJOR=13 MINOR=70 SEQNUM=2264 SUBSYSTEM=input USEC_INITIALIZED=315738

UDEV [78150.408756] add /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/mouse0 (input) ACTION=add DEVLINKS=/dev/input/by-id/usb-04d9_1400-if01-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.1-mouse DEVNAME=/dev/input/mouse0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0026/input/input45/mouse0 ID_BUS=usb ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_MOUSE=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.1 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=01 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 MAJOR=13 MINOR=32 SEQNUM=2270 SUBSYSTEM=input USEC_INITIALIZED=150349156

and plugout:

KERNEL[78050.382672] remove   /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42/event6 (input)
ACTION=remove
DEVNAME=/dev/input/event6
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42/event6
MAJOR=13
MINOR=70
SEQNUM=2248
SUBSYSTEM=input

UDEV [78050.385911] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42/event6 (input) ACTION=remove DEVLINKS=/dev/input/by-id/usb-04d9_1400-event-kbd /dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.0-event-kbd DEVNAME=/dev/input/event6 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42/event6 ID_BUS=usb ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_KEYBOARD=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.0 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_0 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=00 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 MAJOR=13 MINOR=70 SEQNUM=2248 SUBSYSTEM=input USEC_INITIALIZED=215964

KERNEL[78050.399307] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42 (input) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42 EV=120013 KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe LED=7 MODALIAS=input:b0003v04D9p1400e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8C,8E,96,98,9E,9F,A1,A3,A4,A5,A6,AD,B0,B1,B2,B3,B4,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input0" PRODUCT=3/4d9/1400/110 PROP=0 SEQNUM=2249 SUBSYSTEM=input UNIQ=""

KERNEL[78050.399658] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/hidraw/hidraw0 (hidraw) ACTION=remove DEVNAME=/dev/hidraw0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/hidraw/hidraw0 MAJOR=247 MINOR=0 SEQNUM=2250 SUBSYSTEM=hidraw

KERNEL[78050.399744] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023 (hid) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input0 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2251 SUBSYSTEM=hid

KERNEL[78050.399821] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 (usb) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 DEVTYPE=usb_interface INTERFACE=3/1/1 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip01in00 PRODUCT=4d9/1400/143 SEQNUM=2252 SUBSYSTEM=usb TYPE=0/0/0

UDEV [78050.402035] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42 (input) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/input/input42 EV=120013 ID_BUS=usb ID_FOR_SEAT=input-pci-0000_00_1d_0-usb-0_1_1_0 ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_KEYBOARD=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.0 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_0 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=00 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe LED=7 MODALIAS=input:b0003v04D9p1400e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,8C,8E,96,98,9E,9F,A1,A3,A4,A5,A6,AD,B0,B1,B2,B3,B4,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input0" PRODUCT=3/4d9/1400/110 PROP=0 SEQNUM=2249 SUBSYSTEM=input TAGS=:seat: UNIQ="" USEC_INITIALIZED=215881

UDEV [78050.403745] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/hidraw/hidraw0 (hidraw) ACTION=remove DEVNAME=/dev/hidraw0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023/hidraw/hidraw0 MAJOR=247 MINOR=0 SEQNUM=2250 SUBSYSTEM=hidraw USEC_INITIALIZED=50400126

UDEV [78050.405656] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023 (hid) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0/0003:04D9:1400.0023 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input0 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2251 SUBSYSTEM=hid USEC_INITIALIZED=400682

UDEV [78050.407323] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 (usb) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.0 DEVTYPE=usb_interface ID_MODEL_FROM_DATABASE=PS/2 keyboard + mouse controller ID_VENDOR_FROM_DATABASE=Holtek Semiconductor, Inc. INTERFACE=3/1/1 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip01in00 PRODUCT=4d9/1400/143 SEQNUM=2252 SUBSYSTEM=usb TYPE=0/0/0 USEC_INITIALIZED=197298

KERNEL[78050.432446] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/event7 (input) ACTION=remove DEVNAME=/dev/input/event7 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/event7 MAJOR=13 MINOR=71 SEQNUM=2253 SUBSYSTEM=input

UDEV [78050.434993] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/event7 (input) ACTION=remove DEVLINKS=/dev/input/by-id/usb-04d9_1400-if01-event-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.1-event-mouse DEVNAME=/dev/input/event7 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/event7 ID_BUS=usb ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_MOUSE=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.1 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=01 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 MAJOR=13 MINOR=71 SEQNUM=2253 SUBSYSTEM=input USEC_INITIALIZED=248972

KERNEL[78050.456155] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/mouse0 (input) ACTION=remove DEVNAME=/dev/input/mouse0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/mouse0 MAJOR=13 MINOR=32 SEQNUM=2254 SUBSYSTEM=input

UDEV [78050.457413] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/mouse0 (input) ACTION=remove DEVLINKS=/dev/input/by-id/usb-04d9_1400-if01-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.1-mouse DEVNAME=/dev/input/mouse0 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43/mouse0 ID_BUS=usb ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_MOUSE=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.1 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=01 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 MAJOR=13 MINOR=32 SEQNUM=2254 SUBSYSTEM=input USEC_INITIALIZED=249005

KERNEL[78050.490161] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43 (input) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43 EV=17 KEY=1f0000 2000000 39fad941d001 1e000000000000 0 MODALIAS=input:b0003v04D9p1400e0110-e0,1,2,4,k71,72,73,74,80,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,AB,AC,AD,D9,110,111,112,113,114,r0,1,8,am4,lsfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input1" PRODUCT=3/4d9/1400/110 PROP=0 REL=103 SEQNUM=2255 SUBSYSTEM=input UNIQ=""

KERNEL[78050.490227] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/hidraw/hidraw1 (hidraw) ACTION=remove DEVNAME=/dev/hidraw1 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/hidraw/hidraw1 MAJOR=247 MINOR=1 SEQNUM=2256 SUBSYSTEM=hidraw

UDEV [78050.490261] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/hidraw/hidraw1 (hidraw) ACTION=remove DEVNAME=/dev/hidraw1 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/hidraw/hidraw1 MAJOR=247 MINOR=1 SEQNUM=2256 SUBSYSTEM=hidraw USEC_INITIALIZED=489761

KERNEL[78050.490301] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024 (hid) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input1 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2257 SUBSYSTEM=hid

KERNEL[78050.490340] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 (usb) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 DEVTYPE=usb_interface INTERFACE=3/1/2 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip02in01 PRODUCT=4d9/1400/143 SEQNUM=2258 SUBSYSTEM=usb TYPE=0/0/0

UDEV [78050.491393] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43 (input) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024/input/input43 EV=17 ID_BUS=usb ID_FOR_SEAT=input-pci-0000_00_1d_0-usb-0_1_1_1 ID_INPUT=1 ID_INPUT_KEY=1 ID_INPUT_MOUSE=1 ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_ID=1400 ID_PATH=pci-0000:00:1d.0-usb-0:1:1.1 ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_TYPE=hid ID_USB_DRIVER=usbhid ID_USB_INTERFACES=:030101:030102: ID_USB_INTERFACE_NUM=01 ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_ID=04d9 KEY=1f0000 2000000 39fad941d001 1e000000000000 0 MODALIAS=input:b0003v04D9p1400e0110-e0,1,2,4,k71,72,73,74,80,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,AB,AC,AD,D9,110,111,112,113,114,r0,1,8,am4,lsfw MSC=10 NAME="HID 04d9:1400" PHYS="usb-0000:00:1d.0-1/input1" PRODUCT=3/4d9/1400/110 PROP=0 REL=103 SEQNUM=2255 SUBSYSTEM=input TAGS=:seat: UNIQ="" USEC_INITIALIZED=248939

UDEV [78050.491500] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024 (hid) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1/0003:04D9:1400.0024 HID_ID=0003:000004D9:00001400 HID_NAME=HID 04d9:1400 HID_PHYS=usb-0000:00:1d.0-1/input1 MODALIAS=hid:b0003g0001v000004D9p00001400 SEQNUM=2257 SUBSYSTEM=hid USEC_INITIALIZED=489833

UDEV [78050.491546] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 (usb) ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1/5-1:1.1 DEVTYPE=usb_interface ID_MODEL_FROM_DATABASE=PS/2 keyboard + mouse controller ID_VENDOR_FROM_DATABASE=Holtek Semiconductor, Inc. INTERFACE=3/1/2 MODALIAS=usb:v04D9p1400d0143dc00dsc00dp00ic03isc01ip02in01 PRODUCT=4d9/1400/143 SEQNUM=2258 SUBSYSTEM=usb TYPE=0/0/0 USEC_INITIALIZED=32216435

KERNEL[78050.509101] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1 (usb) ACTION=remove BUSNUM=005 DEVNAME=/dev/bus/usb/005/013 DEVNUM=013 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1 DEVTYPE=usb_device MAJOR=189 MINOR=524 PRODUCT=4d9/1400/143 SEQNUM=2259 SUBSYSTEM=usb TYPE=0/0/0

UDEV [78050.509856] remove /devices/pci0000:00/0000:00:1d.0/usb5/5-1 (usb) ACTION=remove BUSNUM=005 DEVNAME=/dev/bus/usb/005/013 DEVNUM=013 DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-1 DEVTYPE=usb_device ID_BUS=usb ID_MODEL=1400 ID_MODEL_ENC=1400 ID_MODEL_FROM_DATABASE=PS/2 keyboard + mouse controller ID_MODEL_ID=1400 ID_REVISION=0143 ID_SERIAL=04d9_1400 ID_USB_INTERFACES=:030101:030102: ID_VENDOR=04d9 ID_VENDOR_ENC=04d9 ID_VENDOR_FROM_DATABASE=Holtek Semiconductor, Inc. ID_VENDOR_ID=04d9 MAJOR=189 MINOR=524 PRODUCT=4d9/1400/143 SEQNUM=2259 SUBSYSTEM=usb TYPE=0/0/0 USEC_INITIALIZED=32193478

  • What does udevadm monitor -p show when you plug/unplug the keyboard? – jasonwryan Jan 6 '15 at 19:30
  • 1
    Check your log (journalctl -b). You should have some errors like failed to execute '/home/rob/home/scripts......sh' '/home/rob/home/scripts....sh': Exec format error. If so, change the values for the RUN keys in your udev rule like this: RUN+="/usr/bin/sh -c '/home/rob/.......sh'". Note you have to use the full path for sh (you can get it with whereis -b sh). – don_crissti Jan 9 '15 at 19:24
  • Could you post the full setup (add used scripts)? – user.dz Jul 12 '15 at 17:15
1

From what I see, there could be two problems.

  1. The scripts does not have 777 permissions.
  2. The way you are invoking. Try as below. They should work.

The udev rule file

$ cat 080-model-m.rules 
ACTION=="add", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="1400", RUN+="/bin/sh /home/rob/home/scripts/caps-equals-super.sh"

ACTION=="remove", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="1400", RUN+="/bin/sh /home/rob/home/scripts/revert-keyboard-to-default.sh"

Note the /bin/sh in the beginnig of RUN. Also, cross check the path of the shell script once again.

Also once you made the changes to the udev rules, make sure to do udevadm trigger so that the udev rules are reloaded

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.