How to remove or disable a default keyboard layout?

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

In OS X 10.9, this preference pane has been redesigned, but still there’s no way to “remove” the built-in “U.S.” keyboard layout:

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.


Solution 1:

For macOS 10.8 and later:

  1. Change the current input source to your custom keyboard layout.
  2. Open ~/Library/Preferences/com.apple.HIToolbox.plist (in 10.9) or ~/Library/Preferences/ByHost/com.apple.HIToolbox.*.plist (in 10.8 and earlier). You can convert the plist to XML with plutil -convert xml1.
  3. Remove the input source or input sources you want to disable from the AppleEnabledInputSources dictionary. If there is an AppleDefaultAsciiInputSource key, remove it.
  4. Restart.

For macOS 10.7 and earlier:

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

Solution 2:

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.

Solution 3:

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.

Solution 4:

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.