Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
macOS input method change tool
#include <stdio.h>
#include <string.h>
#include <Carbon/Carbon.h>
int main(int nargs, char** argv) {
if (nargs != 2) {
fprintf(stderr, "%s (on|off)\n", argv[0]);
return 1;
TISInputSourceRef is = NULL;
if (strcmp(argv[1], "on") == 0) {
NSString *locale = [[NSLocale currentLocale] localeIdentifier];
is = TISCopyInputSourceForLanguage(locale);
} else if (strcmp(argv[1], "off") == 0) {
is = TISCopyCurrentASCIICapableKeyboardInputSource();
} else {
fprintf(stderr, "%s (on|off)\n", argv[0]);
return 1;
if (is) TISSelectInputSource(is);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.