4

When I connect a bluetooth device (e.g. a wiimote) to my machine and list all device units of systemd via systemctl list-units -t device, the device unit shows up as sys-subsystem-bluetooth-devices-hci0:ID.device.

Problem:

I want to bind a systemd service to a specific bluetooth device unit (e.g. wiimote). Thus, I will need an idea about the name. The ID differs on two Arch linux machines.

Questions:

  • Who assigns these device IDs to bluetooth systemd device units?
  • Is the ID static on one system and among system updates and thus is it safe binding services to that device unit, i.e., will this service only be triggered when connecting a bluetooth device of the same type?
  • Can I change/influence this ID?

Attempts:

I tried to change the ID with an udev rule following this description on the Arch wiki. Via udevadm info -a -p $(udevadm info -q path -n /dev/hidraw4 ) I got:

looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/bluetooth/hci0/hci0:256/0005:057E:0330.000C/hidraw/hidraw4':
KERNEL=="hidraw4"
SUBSYSTEM=="hidraw"
DRIVER==""

looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/bluetooth/hci0/hci0:256/0005:057E:0330.000C':
KERNELS=="0005:057E:0330.000C"
SUBSYSTEMS=="hid"
DRIVERS=="wiimote"
ATTRS{country}=="00"
ATTRS{devtype}=="gen20"
ATTRS{extension}=="none"

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

All KERNEL(S) entries are not the same over two systems. I thus tried to apply the udev rule:

SUBSYSTEMS=="hid", DRIVERS=="wiimote", TAG+="systemd", SYMLINK+="wii"

But that doesn't create any additional device unit.

0

1 Answer 1

1

You need to add:

ENV{SYSTEMD_ALIAS}="/dev/wii"

(which is what SYMLINK+="wii" creates) to your udev rule.

After path normalisation, this results in dev-wii.device.

(NB: this sounds so simple, but it took me some hours to arrive at, so I'm by no means dismissing it as an easy question! I struggled with it for my own purposes, coming across your question hoping for a solution for myself.)

Tangentially, if your udev rule is split over multiple lines, the breaks escaped with \, you also need to ensure that the file ends with an empty line. Otherwise, it appears to be parsed by udev (it's not like the EOF character is somehow escaped) but doesn't achieve the desired result.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .