I have configured correctly two keyboard layouts, one for the incorporated keyboard (english) and one for an external usb keyboard (spanish), so for I have to switch manually between them.
Is there a way to configure Ubuntu so that when I connect the external USB keyboard it automatically changes to the Spanish layout ? (and when disconnected it goes back to English)