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)
These are the steps to make linux switch between keyboard layouts when you connect an external USB keyboard
switchKeyboard.sh
that switches between the two layouts that you haveNote that running the above script will not reflect in the visual keyboard indicator on top, but if you type on any console or app you will notice the changes, also there is room for improvement to make it more generic and readable
keyboardDisConnected.py
python keyboardDisConnected.py
, connect and disconnect your usb keyboard you should see something similar to this:References: