Here's a video of my milling machine's two speed gearbox working under LinuxCNC control. You can find the LinuxCNC config files here: https://forum.linuxcnc.org/40-subroutines-and-ngcgui/35819-two-speed-spindle-gear-changer-for-vmc
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.