Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Switch TO specific input source

I want to do something like: set keyboard layout to 'QWERTY' or something like that.

share|improve this question

marked as duplicate by Daniel Beck, BinaryMisfit Jan 21 '11 at 11:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The current keyboard layout appears to be saved in ~/Library/Preferences/ByHost/ under the key AppleCurrentKeyboardLayoutInputSourceID. Your ID is a 12-digit hexadecimal number. Inspect the ByHost folder to see what I mean.

You can write preferences to this file using the defaults command in Terminal. For example, the following commands change this preference to the US keyboard then restart SystemUIServer, the process that handles the Input Source menu.

defaults write ~/Library/Preferences/ByHost/ AppleCurrentKeyboardLayoutInputSourceID -string ""
killall SystemUIServer

However, this seems to change the keyboard only about 80% of the time.

You can run Terminal commands from AppleScript easily using do shell script.

share|improve this answer

This may be useful, you'll need to change the names. It may be out of date, if it is here is the newer workflow. It's odd, no-one seems to have done this in the last five or so years.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.