我希望我的计算机在 (1) 插入、(2) 拔出、(3) 启动时检测到特定键盘时运行某些脚本。
这是该设备:
[rob@X200 vim]$ lsusb | grep keyb
Bus 005 Device 012: ID 04d9:1400 Holtek Semiconductor, Inc. PS/2 keyboard + mouse controller
这是 .rules 文件:
[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"
这些脚本已经过测试,可以正常工作,但不会在设备插入/拔出时触发。我不太确定如果在启动时检测到键盘,我将如何触发脚本,但我想我必须告诉某些东西(systemd,udev?)在某些资源准备好之前不要运行脚本。
这是udevadm monitor -p
设备插件:
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
和插头:
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
答案1
从我看来,可能存在两个问题。
- 该脚本没有 777 权限。
- 你调用的方式。尝试如下。他们应该工作。
udev 规则文件
$ 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"
请注意/bin/sh
开头的RUN
。另外,再次交叉检查 shell 脚本的路径。
另外,一旦您对 udev 规则进行了更改,请确保udevadm trigger
重新加载 udev 规则