diff --git a/README.md b/README.md index 2535f93..ae77f87 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ * [Archlinux](./linux/arch/README.md) * [Installation instructions for UEFI + GPT](./linux/arch/installation.md) * [Shell commands](./linux/shell_commands.md) + * [udev](./linux/udev.md) * [MySQL](./MySQL/README.md) * [ODroid](./odroid.md) * [OpenSSL](./OpenSSL.md) diff --git a/linux/udev.md b/linux/udev.md new file mode 100644 index 0000000..8d3f83e --- /dev/null +++ b/linux/udev.md @@ -0,0 +1,20 @@ +# udev + +## Start (and stop) a systemd daemon + +Create a udev rule to start the daemon: +``` +% cat /etc/udev/rules.d/10-bluetooth-service.rules +ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0a5c", ATTRS{idProduct}=="21e8", TAG+="systemd", ENV{SYSTEMD_WANTS}="bluetooth.service" +``` +This one starts the bluetooth systemd service when a specific usb bluetooth dongle is added to the system. + +If you need to find `idVendor` and `idProduct` you can start `udevadm monitor --property` while plugging the usb device in and out. + +To stop the daemon again you need to edit the systemd service file of the daemon - in this case `systemctl edit bluetooth.service`: +``` +[Unit] +BindsTo=sys-subsystem-bluetooth-devices-hci0.device +After=sys-subsystem-bluetooth-devices-hci0.device +``` +The device name in this case is found by `systemctl list-units --all --full | grep "\.device"`.