Posted on 06-28-2019 09:41 AM
Hi all,
Does anyone know how to add a second input source to the keyboard? I have the keyboard ID, but don't know how to add it to the input sources?
I would also like to show the input menu in menu bar for users.
Thanks in advance for any guidance.
Posted on 11-12-2019 09:39 AM
@donifar Also have a need for this but have yet to find any solution. Surprised this isn't more common.
Posted on 11-13-2019 03:40 AM
We used to reset these settings to our defaults on lab Macs in the past. I'd suggest you want to do this via a custom configuration profile as these settings are user level. Scripting them will be far more complex than deploying a config profile.
To add the Menu bar option the preference is com.apple.systemuiserver.plist the necessary plist content is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>menuExtras</key>
<array>
<string>/System/Library/CoreServices/Menu Extras/TextInput.menu</string>
</array>
<key>NSStatusItem Visible com.apple.menuextra.textinput</key>
<true/>
</dict>
</plist>
The preference holding the keyboard info is com.apple.HIToolbox.plist, add your required keyboards in the System Preferences then, again, use this to create a custom config profile. For example, British and Australian, with British as default would be:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppleCurrentKeyboardLayoutInputSourceID</key>
<string>com.apple.keylayout.British</string>
<key>AppleEnabledInputSources</key>
<array>
<dict>
<key>InputSourceKind</key>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<integer>2</integer>
<key>KeyboardLayout Name</key>
<string>British</string>
</dict>
<dict>
<key>InputSourceKind</key>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<integer>15</integer>
<key>KeyboardLayout Name</key>
<string>Australian</string>
</dict>
</array>
<key>AppleSelectedInputSources</key>
<array>
<dict>
<key>InputSourceKind</key>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<integer>2</integer>
<key>KeyboardLayout Name</key>
<string>British</string>
</dict>
</array>
</dict>
</plist>
Posted on 02-19-2020 12:01 PM
Recently had someone point me to this question. It's possible to use the defaults command to add an input source. I have an example on GitHub.
Here's a short script:
#!/bin/zsh
# adds the additional input source to the list of input sources
/usr/bin/defaults write com.apple.HIToolbox AppleEnabledInputSources -array-add '<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>89</integer><key>KeyboardLayout Name</key><string>Latin American</string></dict>'
# enables the input menu in the menu bar
/usr/bin/defaults write com.apple.TextInputMenu visible -bool true
exit 0
Posted on 01-14-2024 05:19 PM
Thanks @talkingmoose that works great. What I noticed though is that you don't see the change until after you logout and log back in. I tried restarting the menu bar using
killall -KILL SystemUIServer
and it did restart the menubar but didn't load the added input source. Any ideas on whether it is possible to reload that list without the logout/login?
Posted on 10-06-2020 02:40 AM
Any one can tell me how to find out the keyboard ID
Posted on 11-27-2020 02:54 AM
@luic6 try this. defaults read /Library/Preferences/com.apple.HIToolbox.plist AppleEnabledInputSources
Posted on 11-27-2020 03:04 AM
@talkingmoose I used your script, thnx for that. Now when I open my system prefs I have 2 how do I make the just added one default? Or how can I remove one?
thnx
Posted on 12-08-2020 08:56 PM
@talkingmoose jamf should give the smartest way to do it...