Você pode usar o KeyRemap4MacBook :
k=/Applications/KeyRemap4MacBook.app/Contents/Applications/KeyRemap4MacBook_cli.app/Contents/MacOS/KeyRemap4MacBook_cli
$k changed | grep -q ^remap.commandL2optionL= && mode=disable || mode=enable
$k $mode remap.commandL2optionL
$k $mode remap.commandR2optionR
$k $mode remap.optionL2commandL
$k $mode remap.optionrcommandr
Você pode pressionar o comando shift-F1 e a opção pressionando um private.xml assim:
<?xml version="1.0"?>
<root>
<item>
<name>toggleoptcmd</name>
<identifier>toggleoptcmd</identifier>
<autogen>__KeyToKey__ KeyCode::F1, VK_SHIFT | ModifierFlag::NONE,
KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen>
</item>
<item>
<name>swapoptcmd</name>
<identifier vk_config="true">swapoptcmd</identifier>
<autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen>
</item>
</root>
Isso trocaria opção e comando somente quando o TextEdit estiver na frente:
<?xml version="1.0"?>
<root>
<appdef>
<appname>TEXTEDIT</appname>
<equal>com.apple.TextEdit</equal>
</appdef>
<item>
<name>swapoptcmdtextedit</name>
<identifier>swapoptcmdtextedit</identifier>
<only>TEXTEDIT</only>
<autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen>
</item>
</root>
Outra opção é usar o AppleScript:
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell window 1 of process "System Preferences"
click button "Modifier Keys…" of tab group 1
tell sheet 1
--tell pop up button 5
--click
--click menu item "Apple Wireless Keyboard" of menu 1
--end tell
if value of pop up button 1 is "⌘ Command" then
tell pop up button 1
click
click menu item "⌥ Option" of menu 1
end tell
tell pop up button 2
click
click menu item "⌘ Command" of menu 1
end tell
else
tell pop up button 1
click
click menu item "⌘ Command" of menu 1
end tell
tell pop up button 2
click
click menu item "⌥ Option" of menu 1
end tell
end if
click button "OK"
end tell
end tell
quit application "System Preferences"