2

Is it possible to use wildcard characters when writing udev rules? I have multiseat and i want to assign every device (keyboard, mouse etc) that gets connected to a certain USB hub - or even better, a specific port on the front of the PC - to seat1. It's kind of cumbersome to have to redo new rules each time i swap stuff around or don't remember in which USB slot each device was connected.

Using just simple udev rules, as generated by 'loginctl attach' command:

TAG=="seat", ENV{ID_FOR_SEAT}=="usb-pci-0000_00_14_0-usb-0_5_3", ENV{ID_SEAT}="seat1"
5
  • Maybe its a good idea, to add the code you have already to the question.
    – Marco
    Commented Jul 26, 2023 at 5:08
  • @Marco thanks, done. No idea how i didn't think of that =)
    – dolt
    Commented Jul 26, 2023 at 14:40
  • 1
    UDEV rules accept some simple shell style pattern matching ... So, something like usb-pci-* should work.
    – Raffa
    Commented Jul 26, 2023 at 14:53
  • Also please see how pattern matching is used here: askubuntu.com/a/1478053/968501
    – Raffa
    Commented Jul 26, 2023 at 15:27
  • @Raffa Thanks, i searched all manpages i could think of, including that one, except not for the phrase "pattern character" ...this is a clear case of poor documentation of udev.
    – dolt
    Commented Jul 26, 2023 at 20:17

2 Answers 2

2

Is it possible to use wildcard characters when writing udev rules?

Yes, it's possible according to man udev:

Most of the fields support shell glob pattern matching and alternate patterns. The following special characters are supported:

   "*"
       Matches zero or more characters.

   "?"
       Matches any single character.

   "[]"
       Matches any single character specified within the brackets. For example, the pattern
       string "tty[SR]" would match either "ttyS" or "ttyR". Ranges are also supported via
       the "-" character. For example, to match on the range of all digits, the pattern
       "[0-9]" could be used. If the first character following the "[" is a "!", any
       characters not enclosed are matched.

   "|"
       Separates alternative patterns. For example, the pattern string "abc|x*" would match
       either "abc" or "x*".
0

I have multiseat and i want to assign every device (keyboard, mouse etc) that gets connected to a certain USB hub

You can assign a USB controller to a seat. Everything that gets plugged into is is automatically assigned to the same seat as the controller.

No wildcard required.

You must log in to answer this question.

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