Posted on 04-24-2015 11:11 AM
Happy Friday,
I want to set the keyboard layout to Swiss German, and have tried the following things (without success):
Created a .dmg of /Library/Preferences/com.apple.HIToolbox.plist (policy FUT/FEU)
Created a Configuration Profile with Custom Settings from an uploaded .plist with all the proper settings.
We have a 'refresh' script that wipes student data on logout and repopulates from the user template. Neither step above changes the keyboard layout for the users. What am I missing? I know that there is a user level setting in ~/Library/ByHost, but shouldn't the User Template trump that?
Thanks!
-tep
Posted on 04-24-2015 11:32 AM
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
defaults delete /Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
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; }'
Posted on 04-24-2015 12:14 PM
@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.
Posted on 04-24-2015 12:44 PM
Hi, if its of use I've blogged our keyboard layout setting code in this article:
http://www.amsys.co.uk/2015/blog/creating-first-boot-script/#.VTqcoc57Urk
and details of a config profile (as an alternative) here:
http://www.amsys.co.uk/2015/blog/creating-config-profiles-instead-first-boot-script/#.VTqc3857Urk
Posted on 09-03-2015 01:33 AM
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?
Posted on 09-03-2015 07:25 AM
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.
Posted on 09-03-2015 08:58 AM
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.
Posted on 02-02-2017 03:22 PM
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
Posted on 11-08-2021 06:47 AM
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.
Posted on 04-03-2017 05:13 AM
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