You are not logged in.

#1 2020-03-01 16:33:06

coldspark
Member
Registered: 2020-02-12
Posts: 8

Create a udev rule for bluetooth pen

I want to create a udev rule, when I my bluetooth pen connects. I have been searching for a long time now and stumbled over this and this

The first one uses the idVendor and idProduct for the device identification and the second one the MAC address. Unfortunately the latter one does not work and I have not yet succeeded to find out the idVendor and idProduct of the device.

When I run udevadm monitor --environment --udev --kernel, I get a lot of informaton, when the pen connects:

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[7361.715656] add      /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4276

UDEV  [7361.723377] add      /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4276
USEC_INITIALIZED=7361722843
SYSTEMD_ALIAS=/sys/subsystem/bluetooth/devices/hci0:3585
SYSTEMD_WANTS=bluetooth.target
SYSTEMD_USER_WANTS=bluetooth.target
TAGS=:systemd:

KERNEL[7362.278434] add      /devices/virtual/misc/uhid/0005:056A:035F.0011 (hid)
ACTION=add
DEVPATH=/devices/virtual/misc/uhid/0005:056A:035F.0011
SUBSYSTEM=hid
HID_ID=0005:0000056A:0000035F
HID_NAME=Bamboo Ink
HID_PHYS=98:3b:8f:32:70:20
HID_UNIQ=d9:60:3b:3b:d1:9e
MODALIAS=hid:b0005g0101v0000056Ap0000035F
SEQNUM=4277

UDEV  [7362.299493] add      /devices/virtual/misc/uhid/0005:056A:035F.0011 (hid)
ACTION=add
DEVPATH=/devices/virtual/misc/uhid/0005:056A:035F.0011
SUBSYSTEM=hid
HID_ID=0005:0000056A:0000035F
HID_NAME=Bamboo Ink
HID_PHYS=98:3b:8f:32:70:20
HID_UNIQ=d9:60:3b:3b:d1:9e
MODALIAS=hid:b0005g0101v0000056Ap0000035F
SEQNUM=4277
USEC_INITIALIZED=7362281137

KERNEL[7362.338900] remove   /devices/virtual/misc/uhid/0005:056A:035F.0011 (hid)
ACTION=remove
DEVPATH=/devices/virtual/misc/uhid/0005:056A:035F.0011
SUBSYSTEM=hid
HID_ID=0005:0000056A:0000035F
HID_NAME=Bamboo Ink
HID_PHYS=98:3b:8f:32:70:20
HID_UNIQ=d9:60:3b:3b:d1:9e
MODALIAS=hid:b0005g0101v0000056Ap0000035F
SEQNUM=4278

UDEV  [7362.340652] remove   /devices/virtual/misc/uhid/0005:056A:035F.0011 (hid)
ACTION=remove
DEVPATH=/devices/virtual/misc/uhid/0005:056A:035F.0011
SUBSYSTEM=hid
HID_ID=0005:0000056A:0000035F
HID_NAME=Bamboo Ink
HID_PHYS=98:3b:8f:32:70:20
HID_UNIQ=d9:60:3b:3b:d1:9e
MODALIAS=hid:b0005g0101v0000056Ap0000035F
SEQNUM=4278
USEC_INITIALIZED=7362338916

KERNEL[7362.391330] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4279

UDEV  [7362.394328] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4279
USEC_INITIALIZED=7361722843
SYSTEMD_ALIAS=/sys/subsystem/bluetooth/devices/hci0:3585
SYSTEMD_WANTS=bluetooth.target
SYSTEMD_USER_WANTS=bluetooth.target
TAGS=:systemd:

I don't know what to make of it.

I've been trying to create the udev rules like so

# Run a program when my Bamboo Ink is connected
ACTION=="add" , SUBSYSTEM=="bluetooth", DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585", SYSTEMD_ALIAS=="/sys/subsystem/bluetooth/devices/hci0:3585", RUN+="xournalpp"

and so

# Run a program when my Bamboo Ink is connected
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{address}=="d9:60:3b:3b:d1:9e", RUN+="xournalpp"

I get no response. I also don't really know what I am doing. Would be grateful if you could clarify what the output of udevadm monitor means and what information I need to identify the pen.

Offline

#2 2020-03-04 08:55:15

coldspark
Member
Registered: 2020-02-12
Posts: 8

Re: Create a udev rule for bluetooth pen

I found the necessary information

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:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585':
    KERNEL=="hci0:3585"
    SUBSYSTEM=="bluetooth"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0':
    KERNELS=="hci0"
    SUBSYSTEMS=="bluetooth"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0':
    KERNELS=="1-7:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="btusb"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{authorized}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="03"
    ATTRS{bInterfaceClass}=="e0"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bInterfaceProtocol}=="01"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-7':
    KERNELS=="1-7"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{urbnum}=="17523"
    ATTRS{quirks}=="0x0"
    ATTRS{devnum}=="2"
    ATTRS{bcdDevice}=="0010"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceClass}=="e0"
    ATTRS{devpath}=="7"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="01"
    ATTRS{version}==" 2.00"
    ATTRS{authorized}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{maxchild}=="0"
    ATTRS{rx_lanes}=="1"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{devspec}=="(null)"
    ATTRS{idVendor}=="8087"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{busnum}=="1"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{speed}=="12"
    ATTRS{idProduct}=="0a2b"
    ATTRS{removable}=="fixed"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{rx_lanes}=="1"
    ATTRS{manufacturer}=="Linux 5.5.7-1-MANJARO xhci-hcd"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{devpath}=="0"
    ATTRS{devnum}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bcdDevice}=="0505"
    ATTRS{serial}=="0000:00:14.0"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{tx_lanes}=="1"
    ATTRS{busnum}=="1"
    ATTRS{idProduct}=="0002"
    ATTRS{speed}=="480"
    ATTRS{idVendor}=="1d6b"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{authorized}=="1"
    ATTRS{configuration}==""
    ATTRS{urbnum}=="743"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{version}==" 2.00"
    ATTRS{authorized_default}=="1"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{devspec}=="(null)"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{ltm_capable}=="no"
    ATTRS{bDeviceClass}=="09"
    ATTRS{maxchild}=="12"

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{class}=="0x0c0330"
    ATTRS{devspec}==""
    ATTRS{d3cold_allowed}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{driver_override}=="(null)"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{ari_enabled}=="0"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{enable}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}=="1"
    ATTRS{irq}=="136"
    ATTRS{local_cpus}=="ff"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{subsystem_device}=="0x506d"
    ATTRS{vendor}=="0x8086"
    ATTRS{revision}=="0x21"
    ATTRS{device}=="0x9d2f"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

I already tried

# Run a program when my Bamboo Ink is connected
ACTION=="add" , KERNELS=="0000:00:14.0", SUBSYSTEM=="pci", DRIVER=="xhci_hcd", ATTRS(vendor)=="0x8086", ATTRS(device)=="0x9d2f", RUN+="xournalpp"

and

# Run a program when my Bamboo Ink is connected
ACTION=="add" , KERNELS=="hci0:3585", SUBSYSTEM=="bluetooth", RUN+="xournalpp"

udevadm monitor gives me

KERNEL[6853.936715] add      /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
UDEV  [6853.944142] add      /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
KERNEL[6854.551975] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
UDEV  [6854.554346] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)

so at least the latter one should work. Unfortunately it doesn't.

Offline

Board footer

Powered by FluxBB