ターミナル上で US に切り替える

hoge.m:

#import <Carbon/Carbon.h>
int main() {
  TISInputSourceRef tis = TISCopyCurrentASCIICapableKeyboardInputSource();
  TISSelectInputSource(tis); 
  CFRelease(tis);

  { 
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 
    
    NSDictionary* dic;
    
    NSAppleScript* scriptObject = [[[NSAppleScript alloc] initWithSource:
                @"\
    tell application \"System Events\" to keystroke \" \" using command down\n\
    tell application \"System Events\" to keystroke \" \" using command down"]autorelease];

    NSAppleEventDescriptor* desc = [scriptObject executeAndReturnError:&dic];
    
    [pool release]; 
  }
}


% gcc -framework Carbon -framework Cocoa -o hoge hoge.m
% ./hoge

根本的に考え方が間違ってる...