Voglio un dominio com.apple.keyboard.modifiermapping.1452-628-0
per contenere il seguente array:
(
{
HIDKeyboardModifierMappingDst = 2;
HIDKeyboardModifierMappingSrc = 0;
},
{
HIDKeyboardModifierMappingDst = 0;
HIDKeyboardModifierMappingSrc = 2;
},
{
HIDKeyboardModifierMappingDst = 0;
HIDKeyboardModifierMappingSrc = 10;
}
)
Posso ottenerlo cancellando il valore corrente e eseguendo tre comandi -array-add
:
defaults -currentHost delete -g com.apple.keyboard.modifiermapping.1452-628-0
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array-add '{ HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }'
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array-add '{ HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }'
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array-add '{ HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; }'
defaults -currentHost read -g com.apple.keyboard.modifiermapping.1452-628-0
Quale sintassi posso utilizzare per definire la matrice in un singolo comando?
-
Se eseguo il seguente script:
defaults -currentHost delete -g com.apple.keyboard.modifiermapping.1452-628-0 defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array '( { HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; } )' defaults -currentHost read -g com.apple.keyboard.modifiermapping.1452-628-0
Ricevo un array all'interno di un array:
( ( { HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; } ) )
-
Se provo con
-plist
anziché-array
ottengo unUnexpected argument
. -
Se eseguo il seguente script:
defaults -currentHost delete -g com.apple.keyboard.modifiermapping.1452-628-0 defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-628-0 -array ' { HIDKeyboardModifierMappingDst = 2; HIDKeyboardModifierMappingSrc = 0; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 2; }, { HIDKeyboardModifierMappingDst = 0; HIDKeyboardModifierMappingSrc = 10; }' defaults -currentHost read -g com.apple.keyboard.modifiermapping.1452-628-0
Viene visualizzato un errore di sintassi
defaults[22044:679428] Could not parse: ... Try single-quoting it.
Domanda ancora: quale sintassi posso usare per definire l'array in un singolo comando?