This uses an STM32 microcontroller to act as a USB mass-storage device, serving up a dynamic file. This file can be loaded by the system's boot config to change its boot behaviour based on the physical input:
A full write-up of the process to arrive at this solution is in the project log.
Making one yourself
Source code is available on GitHub.
The entire solution is in code, so all you need is a toggle switch, a USB-capable STM32 microcontroller and an ST-Link programmer. The classic "blue pill" STM32 dev board is already supported (STM32F103). The "black pill" and Adafruit Feather (both STM32F4xx) are capable of this, and support is on the way for those.
Follow the instructions in the GitHub repository to build and flash your chip.
Nice project! I managed to do the "based on a drive presence" one with not much knowledge of bash scripting.
USEFUL TIP if its not working: Disable fast boot from your bios. This got me looking for the reason it wasn't working for a while, but finally found it on another forum and I wanted to share it here.
It results that my computer wasn't initializing all the storage devices so the search command's variable was always "not connected".