As configurações são armazenadas em ~/Library/Preferences/ByHost/.GlobalPreferences*.plist
, mas não sei como aplicar as alterações sem sair e voltar. O KeyRemap4MacBook tem um utilitário de linha de comando que permite desabilitar e habilitar configurações, mas não funciona com o PCKeyboardHack.
Isso só altera as configurações de um teclado e não funciona se o idioma do sistema não for o inglês.
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 1 of tab group 1
tell sheet 1
tell pop up button 4
click
delay 0.1
if value is "⇪ Caps Lock" then
click menu item 2 of menu 1
else
click menu item 1 of menu 1
end if
end tell
click button "OK"
end tell
end tell
quit application "System Preferences"