I already have one way to do this:
function input-switch-darwin() {
cliclick kd:ctrl kp:space ku:ctrl
}
But this is very slow:
❯ time cliclick kd:ctrl kp:space ku:ctrl
cliclick kd:ctrl kp:space ku:ctrl 0.02s user 0.03s system 13% cpu 0.434 total; max RSS 7088
cliclick kd:ctrl kp:space ku:ctrl
. That said, while I'm in Terminal, pressing ctrl+space changes between the two layouts I have, so why can't you just physically press the keys?