Excerpted from
https://github.com/hjuutilainen/dotfiles/blob/master/bin/osx-system-defaults.sh
defaults write /Library/Preferences/com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.SwissGerman"
defaults write /Library/Preferences/com.apple.HIToolbox AppleDefaultAsciiInputSource -dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 19 "KeyboardLayout Name" SwissGerman
Delete the default layouts (US)
defaults delete /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
Enable SwissGerman layout
defaults write /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 19; "KeyboardLayout Name" = SwissGerman; }'
defaults write /Library/Preferences/com.apple.HIToolbox AppleInputSourceHistory -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 19; "KeyboardLayout Name" = SwissGerman; }'
defaults write /Library/Preferences/com.apple.HIToolbox AppleSelectedInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 19; "KeyboardLayout Name" = SwissGerman; }'
@darrell.rennie Thanks for the response. That's the exact same verbiage that I used in my Configuration Profile :-)
I've added this to my Standards script, and will play around with it.
Hi guys
Why are you setting this on the system level and not on the user level? As far as I understand every user has his own keyboard settings in
~/Library/Preferences/com.apple.HIToolbox.plist
How are the two different com.apple.HIToolbox.plist influencing each other?
Hi @tobiaslinder!
You are correct: ~/Library/Preferences/com.apple.HIToolbox.plist is the ticket. My question had more to do with setting the pref universally, but I think I ended up populating the default user template.
Hey @tep
That’s why I was asking. In our standards script the path was really set to
/Libary/Preferences/com.apple.HIToolbox.plist
which doesn’t make any sense to me.
I have a similar issue.
We typically have both Canadian English and Canadian French as the 2 "enabled" keyboard layouts.
I'm trying to come up with a script that will change the keyboard back to Cdn. English on logout (if the student has changed it to Canadian French during their session). I'm having a heck of a time trying to figure it out.
At this point I'm pretty much overwriting the entire plist with my script, but it still doesn't seem be working.
Here's what I've got:
#!/bin/sh
u=student
# set the "current" keyboard layout
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID com.apple.keylayout.Canadian
# set the default keyboard
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleDefaultAsciiInputSource
-dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 29 "KeyboardLayout Name" Canadian
# set the "selected" Input Source
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleSelectedInputSources -array
'<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>29</integer><key>KeyboardLayout Name</key><string>Canadian</string></dict>'
# set enabled keyboards (Canadian English & Canadian French)
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array
'<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>29</integer><key>KeyboardLayout Name</key><string>Canadian</string></dict>'
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array-add
'<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>80</integer><key>KeyboardLayout Name</key><string>Canadian - CSA</string></dict>'
# enable on-screen keyboard and character viewers
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array-add
'<dict><key>Bundle ID</key><string>com.apple.CharacterPaletteIM</string><key>InputSourceKind</key><string>Non Keyboard Input Method</string></dict>'
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array-add
'<dict><key>Bundle ID</key><string>com.apple.KeyboardViewer</string><key>InputSourceKind</key><string>Non Keyboard Input Method</string></dict>'
# fix permissions on plist
chown "$u":staff "/Users/$u/Library/Preferences/"com.apple.HIToolbox.plist
exit
Hello,
I have a Japanese 2012 MacBook Pro. Recently performed a clean install of 10.12.4 and upon booting my jis keyboard is being recognized as a standard US ansi keyboard. Multiple SMC and PRAM resets have no effect. Is there a way to force my Mac to recognize the correct Japanese keyboard?

com.apple.HIToolbox.plist displays the following
bplist00’AppleSelectedInputSourcesAppleEnabledInputSources_AppleInputSourceHistory_'AppleCurrentKeyboardLayoutInputSourceID_AppleDefaultAsciiInputSource°”
InputSourceKindKeyboardLayout Name_KeyboardLayout ID_Keyboard Layout[US Extendedˇˇˇˇˇˇˇ˛°”
°”
_com.apple.keylayout.USExtended”
���/�J�d�é�≠�Ø�∂�»�fi�Ú"$+L���������������������������S
I have a similar issue.
We typically have both Canadian English and Canadian French as the 2 "enabled" keyboard layouts.
I'm trying to come up with a script that will change the keyboard back to Cdn. English on logout (if the student has changed it to Canadian French during their session). I'm having a heck of a time trying to figure it out.
At this point I'm pretty much overwriting the entire plist with my script, but it still doesn't seem be working.
Here's what I've got:
#!/bin/sh
u=student
# set the "current" keyboard layout
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID com.apple.keylayout.Canadian
# set the default keyboard
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleDefaultAsciiInputSource
-dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 29 "KeyboardLayout Name" Canadian
# set the "selected" Input Source
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleSelectedInputSources -array
'<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>29</integer><key>KeyboardLayout Name</key><string>Canadian</string></dict>'
# set enabled keyboards (Canadian English & Canadian French)
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array
'<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>29</integer><key>KeyboardLayout Name</key><string>Canadian</string></dict>'
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array-add
'<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>80</integer><key>KeyboardLayout Name</key><string>Canadian - CSA</string></dict>'
# enable on-screen keyboard and character viewers
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array-add
'<dict><key>Bundle ID</key><string>com.apple.CharacterPaletteIM</string><key>InputSourceKind</key><string>Non Keyboard Input Method</string></dict>'
defaults write "/Users/$u/Library/Preferences/"com.apple.HIToolbox AppleEnabledInputSources -array-add
'<dict><key>Bundle ID</key><string>com.apple.KeyboardViewer</string><key>InputSourceKind</key><string>Non Keyboard Input Method</string></dict>'
# fix permissions on plist
chown "$u":staff "/Users/$u/Library/Preferences/"com.apple.HIToolbox.plist
exit
Hey
I was facing a similar problem and found a solution here
Change OSX keyboard layout("input source") programmatically via terminal or AppleScript?
I used the method with the small m file to compile a little executable with the keyboard layout hard coded in the executable and use a script that runs the executable as the current logged in user. Running the executable as the current logged in user is recommended as each user has an individual keyboard layout. If you set e.g. US for the admin user (or the user createad/used during enrollment) new users would have British layout again. Both the script and the installation of the package are combined in one policy.
In my case I added a second script to run it as non-admin. This script checks if the current logged in user is not in the admin group and if so runs the policy.
I hope this helps.