Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is it possible to remove or disable one of OS X Lion’s default keyboard layouts?

I’m using a custom keyboard layout, and now that I managed to set it as the system-wide default keyboard layout, I’d like to be able to uncheck or remove the built-in “U.S.” keyboard layout that came with OS X. Here’s a screenshot — note that the checkbox is disabled:

Screenshot

Since I never use the U.S. keyboard layout, I’d love to get rid of it, i.e. remove it from the Input menu in the menu bar. How can I do this?


Update: Daniel’s answer doesn’t really answer this question, but it does offer some valuable information regarding this problem:

Mac OS X seems to require at least one keyboard layout that the system recognizes as a “Latin character” layout to be selected.

Assuming this is accurate information (thanks, Daniel!), the question could be rephrased as follows:

How to make OS X consider a custom keyboard to be a Latin character layout?


Update: I just came across something that might help.

share|improve this question
1  
I don't think "Latin" is sufficient. That is easily accomplished in Ukelele by setting the keyboard ID to Roman. I suspect your layout also has to be part of the AppleKeyboardLayouts.bundle in system/library/keyboard layouts. – Tom Gewecke Mar 28 '12 at 14:30

7 Answers

up vote 4 down vote accepted
+100
  1. Enable an input source that isn't like your physical keyboard layout in System Preferences (I used Afghan Dari)
  2. f=~/Library/Preferences/ByHost/com.apple.HIToolbox*.plist; plutil -convert xml1 $f; open $f -e
  3. Remove other input sources except the enabled one and your custom keyboard layout
  4. Log out and back in
  5. Remove the temporarily enabled layout from the property list
  6. Log out and back in

share|improve this answer
This worked flawlessly — I didn’t even have to try the backup plan in your last paragraph. Thank you so much! – Mathias Bynens Aug 13 '12 at 7:53

It appears that you cannot do what you want to without some yet-undiscovered hack to the system. Mac OS X seems to require at least one keyboard layout that the system recognizes as a "Latin character" layout to be selected. This prevents your from being unable to enter your password at the login screen, etc. If you selected French, or Canadian, or another keyboard layout that the system recognizes as Latin characters, you can deselect the US layout.

Your problem is that your custom layout, while containing Latin characters, is not recognized by the system as a Latin keyboard layout, and thus cannot be the only selected keyboard layout. See this question (sadly lacking a great answer) for more information.

Note that a great answer to this question would answer your question also. Alas, my answer here only clarifies what the problem is, but I have no step-by-step solution for you. While such a hack may be possible, I see no evidence that anyone has figured out how to convince Mac OS X that a particular custom keyboard is safe to use as the sole selectable keyboard.

share|improve this answer
Thanks for your detailed clarification of the problem! – Mathias Bynens Mar 21 '12 at 13:29
1  
It probably depends on the physical keyboard you have. People with a Japanese keyboard probably wouldn't be required to enable a "Latin" input method. – Lauri Ranta Aug 9 '12 at 5:54
@Lri I suspect you are correct, but don't have the hardware to test that. Perhaps there's a reader of this site who can? – Daniel Lawson Aug 9 '12 at 13:00

Here's another idea: A few years ago the bundle(s) for Apple Keyboard Layouts were much easier to edit, and this problem seems to have been solvable:

http://hintsforums.macworld.com/archive/index.php/t-71629.html

Perhaps one could still use the old editable bundle, if you could get one from an old system, in the current OS.

share|improve this answer

Here is an idea: After making sure the keyboard id of your custom layout is set to Roman, make a custom AppleKeyboardLayouts.bundle which contains only that layout and substitute this for the one that comes with the OS. (I don't know myself what is involved in creating a .bundle)

share|improve this answer

I just came across something that might help. Here goes:

$ defaults read /Library/Preferences/com.apple.HIToolbox.plist 
{
    AppleCurrentKeyboardLayoutInputSourceID = "com.apple.keylayout.Dutch";
    AppleDefaultAsciiInputSource =     {
        InputSourceKind = "Keyboard Layout";
        "KeyboardLayout ID" = 1337;
        "KeyboardLayout Name" = QWERTY;
    };
    AppleEnabledInputSources =     (
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 26;
            "KeyboardLayout Name" = Dutch;
        }
    );
    AppleInputSourceHistory =     (
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 26;
            "KeyboardLayout Name" = Dutch;
        }
    );
    AppleSelectedInputSources =     (
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 26;
            "KeyboardLayout Name" = Dutch;
        }
    );
}

This is on my system, where my custom keyboard layout (named “QWERTY”) is the default. Note that the KeyboardLayout Name and KeyboardLayout ID properties refer to the ID and name at the start of the .keylayout file.

As you can see, defaults read /Library/Preferences/com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID still returns the string "com.apple.keylayout.Dutch". Is there a list somewhere of the available com.apple.keylayout values? Is it possible to get such a value for a custom keyboard layout? ’Cause in that case, we could simply override the property.

Also, the AppleEnabledInputSources, AppleInputSourceHistory, and AppleSelectedInputSources properties all seem to ignore the custom keyboard layout, as their values correspond to the native OS X keyboard layout I originally selected when running Setup Assistant.


Another update: Aha! Seems like there’s another plist file from which we might be able to copy the settings.

$ defaults read ~/Library/Preferences/ByHost/com.apple.HIToolbox.*.plist 
{
    AppleCurrentKeyboardLayoutInputSourceID = "org.unknown.keylayout.QWERTY";
    AppleDateResID =     {
        smRoman = 2;
    };
    AppleEnabledInputSources =     (
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 26;
            "KeyboardLayout Name" = Dutch;
        },
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 1337;
            "KeyboardLayout Name" = QWERTY;
        },
                {
            "Bundle ID" = "com.apple.CharacterPaletteIM";
            InputSourceKind = "Non Keyboard Input Method";
        },
                {
            "Bundle ID" = "com.apple.KeyboardViewer";
            InputSourceKind = "Non Keyboard Input Method";
        },
                {
            "Bundle ID" = "com.apple.inputmethod.ironwood";
            InputSourceKind = "Non Keyboard Input Method";
        }
    );
    AppleGlobalTextInputProperties =     {
        TextInputGlobalPropertyPerContextInput = 0;
    };
    AppleInputSourceHistory =     (
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 1337;
            "KeyboardLayout Name" = QWERTY;
        },
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 26;
            "KeyboardLayout Name" = Dutch;
        }
    );
    AppleNumberResID =     {
        smRoman = 2;
    };
    AppleSelectedInputSources =     (
                {
            InputSourceKind = "Keyboard Layout";
            "KeyboardLayout ID" = 1337;
            "KeyboardLayout Name" = QWERTY;
        },
                {
            "Bundle ID" = "com.apple.inputmethod.ironwood";
            InputSourceKind = "Non Keyboard Input Method";
        }
    );
    AppleTimeResID =     {
        smRoman = 2;
    };
}

As you can see (AppleCurrentKeyboardLayoutInputSourceID), apparently custom keyboard layouts get values like "org.unknown.keylayout.FOO" where FOO is the name of the keyboard layout (as specified in the .keylayout file).

So, to let’s try setting all values to our custom keyboard layout, named QWERTY and with ID 1337 (specified in the .keylayout file):

sudo defaults write /Library/Preferences/ByHost/com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID -string "org.unknown.keylayout.QWERTY"

Sadly, this doesn’t seem to work.

Update: @Lri discovered a reliable method — see his answer.

share|improve this answer

For the sake of completeness, I filed this as bug ID #11137961 with Apple, and this is the response I got:

Bug ID #: 11137961
Bug Title: Allow disabling default (built-in) keyboard layouts when using a custom one


Engineering has determined that this issue behaves as intended based on the following information:

If the issue is just getting your keyboard layout recognized as ASCII-capable, the easiest would be to "bundle" your .keylayout, then your Info.plist can contain a "KLInfo_" dictionary that further describes it, like:

 <key>TISIntendedLanguage</key>
 <string>en</string>   # BCP 47 language string

I'd need to look into this a bit more, but it looks like TIS will scan the keyboard layout output to produce a USet and produce an initial idea of ascii-ness by whether it passes the following minimal test:

 uset_containsRange(uSet, 0x0020, 0x0021) && uset_containsRange(uSet, 0x002C, 0x0039) &&
 uset_containsRange(uSet, 0x003F, 0x005A) && uset_containsRange(uSet, 0x0061, 0x007A);

TIS will also examine the exemplar set for the above indicated locale and require a good dozen or so characters in the range [a-z].

For some suggestions on bundling a .keylayout, also see TextInputSources.h.

If this is still an issue, or you have questions regarding the resolution of this issue, please update your bug report with that information.

We are now closing this bug report.

share|improve this answer

It can be done easily. First change to your custom layout (use menu bar Input menu), then deselect the U.S. layout.

share|improve this answer
My custom layout is the one currently in use. As mentioned in the question, I don’t use the U.S. keyboard layout anymore. – Mathias Bynens Mar 21 '12 at 13:18
I live without U.S. keyboard layout and had no problem to deselect it. The other customizations I have are non-default, non-US region and language. – shpokas Mar 21 '12 at 13:49
Can you deselect the keyboard layout that you chose when setting up the Mac initially? – Mathias Bynens Mar 21 '12 at 13:56
Yes, I can if I change region as well. – shpokas Mar 21 '12 at 20:42
See, that’s the problem. There’s always one of OS X’s built-in keyboard layouts that you cannot delete or disable. – Mathias Bynens Mar 21 '12 at 20:44
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.