--- a/usb_modeswitch_dispatcher.c +++ b/usb_modeswitch_dispatcher.c @@ -320,6 +320,16 @@ strncpy (bus_id, udev_args, length); bus_id[length] = '\0'; + if (strcmp(argv[1], "--switch-systemd") == 0) { + /* When launched via systemd the argument is /, with the - + * replaced by / due to systemd unescaping the unit name before passing it on + * to the executable, re-escape by replacing / by - */ + tmp = kernel_name; + while (tmp = strchr (tmp, '/')) + *tmp = '-'; + } + + if (strlen(kernel_name) > 0 && strlen(bus_id) == 0) { char *colon = strchr (kernel_name, ':');