macOS menu bar: enable the emoji & keyboard viewer icon
Tested on macOS 10.14.5 / 10.14.6. Newer macOS versions manage the menu bar differently – treat this as a starting point.
Snippet from a login script: if the input menu isn’t visible yet, it adds the emoji & symbols viewer, the keyboard viewer and the Austrian keyboard layout, then shows the input menu in the menu bar.
# check if emoji and keyboard setting is active
SYSUI=$(defaults read /Users/student/Library/Preferences/com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.textinput" 2>&1)
if [ "$SYSUI" == "1" ]; then
echo "setting existing..."
else
# emoji & keyboard viewer & keyboard layout Austria
defaults write /Users/student/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/student/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>'
defaults write /Users/student/Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources -array-add '<dict><key>InputSourceKind</key><string>Keyboard Layout</string><key>KeyboardLayout ID</key><integer>92</integer><key>KeyboardLayout Name</key><string>Austrian</string></dict>'
defaults write /Users/student/Library/Preferences/com.apple.systemuiserver "NSStatusItem Visible com.apple.menuextra.textinput" -bool TRUE
defaults write /Users/student/Library/Preferences/com.apple.systemuiserver menuExtras -array-add "/System/Library/CoreServices/Menu Extras/TextInput.menu"
chown ws:staff /Users/student/Library/Preferences/com.apple.systemuiserver.plist
chown ws:staff /Users/student/Library/Preferences/com.apple.HIToolbox.plist
killall -KILL cfprefsd
killall -KILL SystemUIServer
fi
Originally published on anyresearch.net. These are notes from real-world admin work – test before you use them in production.