Lutzifer / keyboardSwitcher

List, show and switch OSX Keyboard Layouts from the command line.
82 stars 10 forks source link

unable to switch to the Pinyin Layout #3

Closed doodzik closed 7 years ago

doodzik commented 8 years ago

I have tried to switch to the Pinyin - Simplified layout, but it didn't work. Switching from U.S. to Dvorak works thought. Below are the steps that I took so you can reproduce it:

``` ❯ keyboardSwitcher get Pinyin - Simplified ❯ keyboardSwitcher select "Pinyin - Simplified" Unknown Layout "(null)": Did you forget to put the identifier in quotation marks? Available Layouts: 2-Set Korean 3-Set Korean 390 Sebulshik ABC ABC - AZERTY ABC - QWERTZ ABC Extended Afghan Dari Afghan Pashto Afghan Uzbek Anjal Arabic Arabic - AZERTY Arabic - North Africa Arabic - PC Arabic - QWERTY Armenian - HM QWERTY Armenian - Western QWERTY Australian Austrian Azeri Bangla Bangla - QWERTY Belarusian Belgian Brazilian Brazilian - ABNT2 Brazilian - Pro British British - PC Bulgarian Bulgarian - Phonetic Canadian English Canadian French - CSA Cangjie Cherokee - Nation Cherokee - QWERTY Colemak Croatian Croatian - PC Czech Czech - QWERTY Danish Devanagari Devanagari - QWERTY Dutch Dvorak Dvorak - Left Dvorak - Qwerty \u2318 Dvorak - Right Estonian Faroese Finnish Finnish Extended Finnish Sami - PC French French - Numerical French - PC Georgian - QWERTY German GongjinCheong Romaja Greek Greek Polytonic Gujarati Gujarati - QWERTY Gurmukhi Gurmukhi - QWERTY Hawaiian Hebrew Hebrew - PC Hebrew - QWERTY HNC Romaja Hungarian Hungarian - QWERTY Icelandic Inuktitut - Nunavut Inuktitut - Nutaaq Inuktitut - QWERTY Inuktitut Nunavik Irish Irish Extended Italian Italian Typewriter Jawi - QWERTY Kana Kannada Kannada - QWERTY Kazakh Khmer Kurdish - Sorani Latvian Lithuanian Macedonian Malayalam Malayalam - QWERTY Maltese Maori Myanmar - QWERTY Nepali Northern Sami Norwegian Norwegian Extended Norwegian Sami - PC Oriya Oriya - QWERTY Persian Persian - ISIRI Persian - QWERTY Polish Polish Pro Portuguese Romanian Romanian - Standard Russian Russian - PC Russian - Phonetic Sami - PC Serbian Serbian - Latin Sinhala Sinhala - QWERTY Slovak Slovak - QWERTY Slovenian Spanish Spanish - ISO Stroke Swedish Swedish - Pro Swedish Sami - PC Swiss French Swiss German Tamil99 Telugu Telugu - QWERTY Thai Thai - PattaChote Tibetan - Otani Tibetan - QWERTY Tibetan - Wylie Tongan Turkish Turkish - QWERTY Turkish - QWERTY PC U.S. U.S. International - PC Ukrainian Ukrainian - PC Unicode Hex Input Urdu Uyghur Vietnamese Welsh Wubi Xing Zhuyin Zhuyin - Eten ```

Great cli program. it is really useful to me 👍

doodzik commented 8 years ago

If you point me to the right direction in the code base I can debug it and submit a pull request :)

Lutzifer commented 8 years ago

sorry for the late answer, just did not see the notification, will have a look

Lutzifer commented 7 years ago

I found a solution for this, which I will include in the next Version. As the next version contains a rewritten CommandLine Interpreter in swift, it could take a while though.

For the meantime, getting the source list like this, to also include InputSources of type kTISTypeKeyboardInputMode, should allow the use of Pinyin:

+ (CFArrayRef) sourceList {
    NSDictionary *keyboardLayoutRefs = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout };
    CFArrayRef keyboardLayoutInputSources = (TISCreateInputSourceList ((__bridge CFDictionaryRef)(keyboardLayoutRefs),true));

    NSDictionary *inputModeRefs = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode };
    CFArrayRef inputModeInputSources = (TISCreateInputSourceList ((__bridge CFDictionaryRef)(inputModeRefs),true));

    NSArray *keyboardLayouArray = (__bridge NSArray*)keyboardLayoutInputSources;
    NSArray *inputModeArray = (__bridge NSArray*)inputModeInputSources;

    NSArray * allSources = [keyboardLayouArray arrayByAddingObjectsFromArray:inputModeArray];

    return (__bridge CFArrayRef)allSources;
}
doodzik commented 7 years ago

Cool, I'll keep an eye open for the release then. Thank you for your time you put into this project :)

Lutzifer commented 7 years ago

with the newly released version 1.0.0

keyboardSwitcher select "Pinyin - Simplified"

works for me.