New udev rule not working on boot

I’m trying to use this script to connect my USB midi devices all-to-all on boot:

It does the right thing when I run the script. When I try to use the udev rule to automate it so that the script runs whenever I plug in a new USB device, it doesn’t work until I run udevadm control --reload. But then, if I reboot, it goes back to not working.

I put the GitHub repo on /udata and then made a symlink to the rules file over in /etc/udev/rules.d. I tried renaming the symlink with a higher number to see if ordering fixed it, but it does not.

Is there something else I need to change so that this works on boot?

Turns out my problem was that the rules were triggering, but it was before aconnect saw the plugged in devices. It would work if I unplugged and re-plugged in the device.

To get it to work on boot, I created a systemd unit. This also had the same problem of running before aconnect was able to see the midi devices, so I also added a systemd timer to run 1s after boot, which made everything work automatically and headless.