I have a few different devices which all accomplish the same basic task. I would like to be able to swap them, and regardless of which one is plugged in, have the same symlink. For example, if I have device1, device2, and device3 and I plug one in to my computer, I want a symlink to be created that is called my_device. However I would like programs running on my computer to know which one is plugged in, preferably through the use of an environment variable, i.e. MY_DEVICE_ID="1".
This is what I have so far:
ACTION=="add", SUBSYSTEM=="usb" ATTRS{...}=="...", SYMLINK+="my_device", ENV{MY_DEVICE_ID}="1"
ACTION=="add", SUBSYSTEM=="usb" ATTRS{....}=="....", SYMLINK+="my_device", ENV{MY_DEVICE_ID}="2"
ACTION=="add", SUBSYSTEM=="usb" ATTRS{.....}==".....", SYMLINK+="my_device", ENV{MY_DEVICE_ID}="3"
Note: Only one device will ever be plugged in at a time. These rules correctly create the symlink, however an environment variable is never set. Why not, and what can I do to accomplish this?
Thanks for your help!
Ubuntu 14.04