It sounds plausible enough to do in code. I assume that the switch isn't wired to the LED so you can set it independently.