At startup, usb-modeswitch automatically switches the dongle to modem mode and the device shows itself as 12d1:1506. After this, a script should run, connecting to the Internet. I am not sure about using /etc/rc.local since Arch has moved to pure systemd. How to I express this dependency (run a script only after the device has switched) in systemd terms?

udev rules cannot run long scripts, and mine is.


The recommended approach would be to have udev start a systemd service, which itself depends on your device.

The service file should look something similar to the following:

my.service - to be placed in /etc/systemd/system

BindsTo=<DEVICE UNIT HERE>.device
After=<DEVICE UNIT HERE>.device


Note: to get a list of the available device units use

list-units --all --full | grep ".device"

And the udev rule should be something like the following:

90-my.rules - to be placed in /etc/udev/rules.d

KERNEL=="tty*", ATTRS{serial}=="<DEVICE SERIAL HERE>", TAG+="systemd", ENV{SYSTEMD_WANTS}="my.service"

Note: to get a list of the attributes of your specific device, including its serial number, use

udevadm info -a -n /dev/tty*

This question, though fairly different, might also be of interest.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.