28

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.

1
  • 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. Commented Mar 28, 2012 at 14:30

12 Answers 12

42
+300

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.

13
  • 1
    Aha, it does seem to work if you restart the computer instead of just logging out and back in (step 4). Thanks! Would you mind posting a new answer with a link to your resource so you can get the bounty? Commented Nov 2, 2013 at 14:05
  • 1
    @MathiasBynens I edited the answer and my website. When I tried the second method again, I also needed to restart to apply the changes.
    – Lri
    Commented Nov 2, 2013 at 18:09
  • 4
    Works fine in OS X 10.9 if you restart your computer. However I had to remove also the temporary layout from the plist file and reboot using 'sudo reboot', otherwise the temporary layout was added back on normal reboot.
    – User366
    Commented Nov 5, 2013 at 20:10
  • 2
    @Lri On 10.9 I had to delete :AppleEnabledInputSources:0 (the old default layout item) and the :AppleInputSourceHistory: dictionary (using PlistBuddy). No reboot, but only logoff necessary.
    – RolKau
    Commented Nov 7, 2013 at 22:50
  • 3
    It still works on macOS 13.2.1 Ventura (M1 Max) 👍 Commented Feb 22, 2023 at 18:24
7
+50

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.

1
  • @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
    Commented Aug 9, 2012 at 13:00
7

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.

3
  • 1
    Checked: my layout meets those criteria but it is not recognised as a possible default layout. So their engineers did not give the full information or gave incorrect information it seems.
    – User366
    Commented Nov 5, 2013 at 20:14
  • 1
    @DmitryDulepov It is possible to use it as the default layout, but the button to remove the other still won't be activated; you would have to do that manually (see my comment to Lri's answer
    – RolKau
    Commented Nov 8, 2013 at 0:57
  • @RolKau, yes but there are other issues later. If you have more than one layout, the new custom layout will not be available in some apps. For example, you will not be able to switch to it in the AppStore's search bar. At least, I could not.
    – User366
    Commented Nov 9, 2013 at 5:55
2

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.

2

After moving my custom keyboard layout to /Library/Keyboard Layouts instead of ~/Library/Keyboard Layouts I could suddenly remove the US layout.

This also fixed the issue I was having where the keyboard layout would switch back to the US layout whenever I activated apps such as Mail or the App Store.

Supposedly this is because if the layout is installed as the current user instead of system wide then system apps can not use it, which would explain why it's not possible to remove the US layout from Preferences.

3
  • This is the only answer that helped me in Monterey 12.2.1 Commented Feb 15, 2022 at 11:02
  • I moved the layouts as suggested from ~/Library/Keyboard Layouts to /Library/Keyboard Layouts but neither did this change anything whatsoever, nor does this allow me to remove the U.S. layout from my system. Cann you guys explain what exactly you did to make this work? One clue also, I couldn't even delete the folder ~/Library/Keyboard Layouts Thanks! Commented Sep 20, 2023 at 11:41
  • Doesn't work for me either. I guess some important piece is missing that makes this possible.
    – Oleksandr
    Commented Apr 2 at 10:26
1

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.

1

Apple’s response to my bug report, in which I was asking to make it possible to remove the system default keyboard layout if another one is selected through System Preferences:

Engineering has determined that this is not an issue for Apple to address.

Assuming this custom keyboard layout is bundled (.keylayout is inside a bundle like foo.bundle/Contents/Resources/foo.keylayout), then this could be as easy as inserting into the Info.plist's KLInfo_ dictionary:

<key>KLInfo_Qwerty</key>
<dict>
  <key>TISInputSourceID</key>
  <string>com.imgur.stack.keyboardlayout.Qwerty</string>
  <key>TISIntendedLanguage</key>  
  <string>en</string> 
</dict>

If this layout is needed system-wide (i.e. including password input) it could be installed in /Library/Keyboard Layouts/, rather than the same location in ~/Library/.

Please update your bug report to let us know whether this is still an issue for you.

If you have questions regarding the resolution of this issue, please update your bug report with them.

Please be sure to regularly check new Apple products for any updates that might affect this issue. Again, thank you for taking the time to submit bugs. We sincerely appreciate your input.

1

I have just had success removing the default layout on High Sierra using the following method:

  1. Navigate to your Library/Preferences folder.
  2. Open the file com.apple.HIToolbox.plist file, either by double-clicking it or by using open on the command line. This will make XCode pop up and it may want to install additional components.
  3. Repeat step 2 until XCode is finally showing the file’s structure.
  4. Locate the AppleEnabledInputSources node and unfold it.
  5. Remove the entry for the layout you want to remove.
  6. Save the file and quit XCode.

Now you probably need to log out or reboot to make this final. I had to reboot anyway for some update so that did the trick for me. Now I’m happily typing along in Neo at an agonizing glacially speed but not a single QWERTZ is in sight!

0

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)

0

You can use Ukelele to mark your used layout as one that uses Latin script. Export as a bundle, install and then you will be able to delete the US one.

0

I tried editing ~/Library/Preferences/com.apple.HIToolbox.plist, as the accepted answer suggests, but every time I saved it, it was automatically reverted back in a few seconds (my system is Sonoma 14.4 @ MacBook Pro M2). After many tries and fails and a long search, I managed to fix it using this method: https://apple.stackexchange.com/a/458984/385704

In case the link dies sometime, here's a brief summary. You shouldn't make edits to com.apple.HIToolbox.plist while logged in to the profile which uses this file. Create another user with admin rights and edit the .plist of your main profile from that new user. Make sure to reboot your mac each time you change users (not just log off/on).

-1

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

8
  • My custom layout is the one currently in use. As mentioned in the question, I don’t use the U.S. keyboard layout anymore. Commented Mar 21, 2012 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
    Commented Mar 21, 2012 at 13:49
  • Can you deselect the keyboard layout that you chose when setting up the Mac initially? Commented Mar 21, 2012 at 13:56
  • Yes, I can if I change region as well.
    – shpokas
    Commented Mar 21, 2012 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. Commented Mar 21, 2012 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .