Created
May 20, 2020 04:01
-
-
Save informationsea/19137be76200b3ac2750b2f4a0ab3f73 to your computer and use it in GitHub Desktop.
macOS input method change tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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