I too use Ubuntu 12.04 and have stuggled with this issue. Using Jason Coombs' answer to his own question as a starting point, I was able to use /etc/default/keyboard to set my keyboard options (for me, ctrl:nocaps and compose:menu) and have that persist across reboots for consoles. However, the setting would be ignored by LightDM/Unity upon reboot. To clarify, I have not set any keyboard preferences from within Unity, so Unity should be defaulting to the system default keyboard settings, but it is not using the keyboard options for some reason.
I noticed that if I run the following command after logging in, Unity suddenly begins to recognize my system default keyboard options:
setxkbmap
I do not supply any parameters to setxkbmap, I merely invoke it with no options and it reads and applies the system default map.
To make this happen automatically when any user logs in (at least, any user with a Gnome or Unity desktop), I have made the following setxkbmap.desktop file that I placed in the /etc/xdg/autostart/ directory:
[Desktop Entry]
Type=Application
TryExec=/usr/bin/setxkbmap
Exec=/usr/bin/setxkbmap
Hidden=false
NoDisplay=true
X-GNOME-Autostart-enabled=true
Name[en_US]=System Keyboard Fix
Name=System Keyboard Fix
Comment[en_US]=Apply system-wide keyboard settings to the session
Comment=Applies system-wide keyboard settings to session
This fix seems to make the keyboard options consistent system-wide, with the exception of the brief period that LightDM has control of my screen before I log in.
Some googling and a test led me to this:
Right click the panel -> Add / Remove Panel Items -> Add -> Keyboard Layout Handler
That adds an icon to the panel, and by right clicking it and selecting "Settings", a GUI tool for managing keyboard layouts shows up.
To add languages, "keep system layout" should be unchecked.
Best Answer
To make a permanent change of the language of the keyboard, write this in the terminal:
This sets the keyboard language to Spanish. This works for Lubuntu 12.04 too.
To just change the keyboard layout for the session, write this in the terminal (this example is for the english language):