This is not the way to go! Which I figured out after digging around and jotting down my findings. Maybe this'll come in handy for someone else, though. The last link in references describes "the way"
I'll risk insulting your intelligence first thing, and just mention that this is for OS X only. Open the terminal and do the below to run the script:
> . {PATH-TO-SCRIPT}/set_defaults.sh
-
Adds, by default, input sources (a.k.a keyboard layouts)
- Swedish
- US international
by adding the layouts to the
com.apple.HIToolbox.plist. -
Makes the Dock "hidden" by default with magnify on scroll over
If you want to change this to suit your needs, I suggest you set the input sources once manually through the System Preferences, check what the values for KeyboardLayout ID and KeyboardLayout Name are in com.apple.HIToolbox.plist, and substitute in the corresponding variables in the script. How to read the .plist is described below!
To see what your file looks like, type defaults read com.apple.HIToolbox. If nothing is returned, or an error of such, it means you don't have a user-level file (yet). When running the script one is created, (thanks to defaults write that does so by default).
{
AppleCurrentKeyboardLayoutInputSourceID = "com.apple.keylayout.Swedish-Pro";
AppleEnabledInputSources = (
{
InputSourceKind = "Keyboard Layout";
"KeyboardLayout ID" = 0;
"KeyboardLayout Name" = "U.S.";
}
);
}
How to add input sources programmatically
- Stackoverflow Q&A clarifying the syntax on how to add a default input source.
- A console layout swticher for Max OSX. Interesting as it is the only place I can find with an indication to how to extract the KeyboardLayout ID if unknown beforehand. (See
xkbswitch/main.m)
Beginning Mac OS X Programming
- defaults write will create a plist file that does not exist
Best description on the alternative methods and why
- Describes a way using the Text Input Services API, which seems far better than my way.
defaultslooks for a preference list file in~/Library/Preferences/. Meaning, you don't need to append a path to find the system generated one (if present), and don't forget that there's no need for the.plistextension.