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
Best Answer
Thanks to the tip by @user3439894, I found an answer (you need ripgrep and https://github.com/myshov/xkbswitch-macosx installed):
Another option is https://github.com/Lutzifer/keyboardSwitcher, but I couldn't build it without xcode.