With the command sudo "/System/Library/CoreServices/Setup Assistant.app/Contents/MacOS/Setup Assistant"
, you have to create a new account for each of current users and do a lot of migration work.
For the current users with wrong keyboard layout, I recommend another way:
sudo cp /Library/Preferences/com.apple.HIToolbox.plist /tmp/
sudo chmod 777 /tmp/com.apple.HIToolbox.plist
plutil -convert xml1 /tmp/com.apple.HIToolbox.plist
Now open /tmp/com.apple.HIToolbox.plist
in a text editor (e.g. vim or Emacs).
Throughout the file you will find several mentions of a KeyboardLayout ID
key followed by an integer and KeyboardLayout Name
followed by a string. Change these strings to the name of your custom keyboard layout and the id integers to the ID of your layout (the easiest way to find the right values is to compare with your user settings found in the file ~/Library/Preferences/com.apple.HIToolbox.plist
sudo cp ~/Library/Preferences/com.apple.HIToolbox.plist /tmp/my.plist
plutil -convert xml1 /tmp/my.plist
cat /tmp/my.plist
Also the value of the key AppleCurrentKeyboardLayoutInputSourceID
must be changed accordingly (for this circumstance it's com.apple.keylayout.Dvorak
). Again you can find this value in your local preference file.
Once these changes are done, save the file and go back to the terminal. To play it safe, you can create a copy of the original com.apple.HIToolbox.plist
file, just in case you made an error and need to roll back. Then do the following:
sudo cp /tmp/com.apple.HIToolbox.plist /Library/Preferences/
sudo chmod 644 /Library/Preferences/com.apple.HIToolbox.plist
Exit the terminal, and restart the computer (logout is not sufficient: the file will not be reread). After restart, you should have your keyboard layout in the login screen. You may need to restart twice.
View Resetting Default Input Method in Mac OS as a refrence.