You can use the setxkbmap command to set and customize all keyboard layout settings in the X Server from the command line.
The setxkbmap command maps the keyboard to use the keyboard layout determined by the options specified on the command line. Configurable options of the setxkbmap command include geometry, keyboard model, layout symbols, layout variant, rules, and the like.
The following example shows how to set two keyboard layouts (US/English and French) from the command line:
$ /usr/bin/setxkbmap us,fr
For more information, see the setxkbmap (1) man page.