Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automate or programmatically make changes to System Preference settings on Mac OS X

I am trying to figure out how to programmatically change System Preference settings on the Mac OS X. If that is not possible, create some post-installation automation script (using Apple Script or other means) and run it as part of the installer. I am particularly interested in making changes to the "Language & Text" settings which are part of the "personal" settings in System Preferences.

Here is more description of my problem:

I am trying to create an installer for a custom keyboard layout I wrote for Mac OS X. The keyboard layout basically allows people to transliterate ASCII keboard input to foreign letters. The foreign language does not exist on Mac OSX*. I was able to use Apple's PackageMaker to create a basic installer that dumps all the necessary files (.keylayout file, icons and the custom fonts) in their respective directories in the target computer. But there are a couple of personal settings that need to be configured in System Preferences before the keyboard layout can be selected and used. I would like to auto-configure these "one-time" settings for the user during the installation process. Is it possible to make changes to the settings using Cocoa/Objective-C. If not, I would like your help on how I can use Apple Script to automate the configuration. Please include some sample code or pointers to examples if possible. Thank you.

Here are the settings that need to be configured on System Preferences

  1. Select System Preferences --> Language & Text -- Input Sources
  2. Select "The Language Name" from the list
  3. Click on "Keyboard Shortcuts" and enable "Select the previous input source" and "Select next source in Input Menu".
  4. Double click on the shortcut combinations "⌘ space" and change them to "⌘ L" for the "Select the previous input source" and "ctrl⌘L" for "Select next source in Input Menu"
  5. Exit systems preference. Done

NB: *The system language need not be changed. Only the input source (keyboard layout).

like image 737
Semere Taézaz Sium Avatar asked Jan 10 '12 01:01

Semere Taézaz Sium


1 Answers

See NSUserDefaults. The values you want to set are probably in NSGlobalDomain.

like image 197
NSResponder Avatar answered Sep 23 '22 19:09

NSResponder