gpt4 book ai didi

udev - 触发特定键盘的 udev 规则

转载 作者:行者123 更新时间:2023-12-04 12:15:36 27 4
gpt4 key购买 nike

我需要为特定键盘编写一个 udev 规则,该规则似乎没有任何可与之匹配的唯一属性。

以下几行是 udevadm monitor 的输出插入设备后。这里有什么我可以用来唯一识别这个键盘的东西吗?

KERNEL[58443.215701] add      /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 (usb)
KERNEL[58443.218536] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
KERNEL[58443.218662] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:04B3:3025.0005 (hid)
KERNEL[58443.221610] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input15 (input)
KERNEL[58443.221669] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input15/event4 (input)
KERNEL[58443.221868] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:04B3:3025.0005/hidraw/hidraw0
UDEV [58443.236718] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 (usb)
UDEV [58443.238026] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
UDEV [58443.239532] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:04B3:3025.0005 (hid)
UDEV [58443.240670] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:04B3:3025.0005/hidraw/hidraw0
UDEV [58443.288767] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input15 (input)
UDEV [58443.319799] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input15/event4 (input)

编辑:

以下是将键盘插入不同 USB 端口的线路。据我所知,似乎没有什么信息是不变的。
KERNEL[59428.187673] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1 (usb)
KERNEL[59428.190323] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0 (usb)
KERNEL[59428.190494] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/0003:04B3:3025.0006 (hid)
KERNEL[59428.193088] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/input/input16 (input)
KERNEL[59428.193266] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/input/input16/event4 (input)
KERNEL[59428.193426] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/0003:04B3:3025.0006/hidraw/hidraw0
UDEV [59428.300690] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1 (usb)
UDEV [59428.301790] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0 (usb)
UDEV [59428.302553] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/0003:04B3:3025.0006 (hid)
UDEV [59428.303130] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/0003:04B3:3025.0006/hidraw/hidraw0
UDEV [59428.319082] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/input/input16 (input)
UDEV [59428.321444] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/input/input16/event4 (input)

编辑:使用 lsusb -v,我能够找到 idVendoridProduct .
Bus 002 Device 009: ID 04b3:3025 IBM Corp. 
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x04b3 IBM Corp.
idProduct 0x3025
bcdDevice 1.09
iManufacturer 1 LITE-ON Technology
iProduct 2 USB NetVista Full Width Keyboard.
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 HID Keyboard
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 70mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 5 EP1 Interrupt
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 65
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 24
Device Status: 0x0000
(Bus Powered)

所以我创建了以下 udev 规则:
SUBSYSTEM=="usb", ATTR{idVendor}=="0x04b3", ATTRS{idProduct}=="0x3025", RUN+="/home/myuser/bin/udev_jap.sh"

但是,到目前为止,没有任何触发。奇怪的是, idVendoridProduct信息未显示在 udevadm monitor .这是否意味着 udev 无法匹配这些属性?

最佳答案

无论如何,这是一个老问题:

  • 您必须删除 0x十六进制前缀。
  • 请注意 ATTRATTRS是不同的,但对于你的情况,两者都应该有效。
  • 您的脚本 udev_jap.sh应该从shebang开始#!/bin/sh或运行 shell 本身:
     RUN+="/bin/sh /home/myuser/bin/udev_jap.sh"

  • 尝试这个:
    SUBSYSTEM=="usb", ATTR{idVendor}=="04b3", ATTR{idProduct}=="3025", RUN+="/home/myuser/bin/udev_jap.sh"

    关于udev - 触发特定键盘的 udev 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20619376/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com