Do you know how to write a `nix shell script? That is how actions are usually tied to the position or change of position of the switches.