Yes there are ways to do this. Its easier if the USB keys can be of different make/model. If it fits into the narrative of the escape room that they look different. If its four identical memsticks that is also possible, just a tad more complicated.
Every USB device has two identifiers called idVendor and idProduct. And whenever a new usb device is plugged into a Linux computer the kernel spits out the following:
Code: Select all
[1975578.241032] usb 1-1.1: New USB device found, idVendor=0930, idProduct=6545
[1975578.241036] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1975578.241038] usb 1-1.1: Product: DataTraveler 2.0
[1975578.241040] usb 1-1.1: Manufacturer: Kingston
The exact values here ( idVendor=0930, idProduct=6545) is for a Kingston 8GB memstick. When I plug in a different model memstick I get:
Code: Select all
[1975581.065550] usb 1-1.4: New USB device found, idVendor=126f, idProduct=0161
[1975581.065570] usb 1-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=3
[1975581.065575] usb 1-1.4: Product: USB Mass Storage Device
Now there is a system in Linux called "udev" that has rules can be used to trigger certain actions/services/etc. when devices are inserted or removed from the system. The actions are defined in "rules" files where you can filter on stuff like idVendor and idProduct.
So how I would do it:
- Add four rules to the "udev" so that when each of the sticks are inserted, we run one of four scripts. The purpose of each script is to send a signal to another program informing it that this particular memstick has been inserted.
- Then the second part is a program (or script) that runs automatically on start and listens for the signal, and based on the signal it will play a specific video.
Biggest questions remaining is:
- What language should the "program" be written in.
Almost any language is possible to use. Bash, Python, C/C++, Node.js...
- Exactly how should we send a signal.
Can be done so simple as to just create a file with a specific name, or one could use more advanced method like pipes or sockets or MQTT.