Ubuntu – Keyboard layout changed. How and why

kdekeyboard-layoutUbuntux11

Yesterday, I upgraded my kernel (to 3.5.0-19-generic), rebooted, and had to reinstall my video drivers to get full resolution. (After upgrading the kernel, the resolution always goes to 640×480, until I reinstall the drivers in Console Login).

Now that I'm back in KDE (I didn't notice if it had changed in the Console Login), my keyboard layout has changed to the US format, so, for example Shift+2 prints @ instead of ".

In KDE's System Settings -> Input Devices -> Keyboard -> Layouts, it seems to show the correct settings:

Map=gb, Layout="English (UK)", Variant="English (UK, extended WinKeys), Label="gb".

That's fine. I changed it and changed it back, and nothing has changed; it's still using the US layout.

After a little googling, I found that there are X server settings, which I've found in /etc/default/keyboard. I've never edited this file before and its last modification (according to ls -l) was a month ago. But in there, XKBLAYOUT="us". It also says:-

# If you change any of the following variables and X is configured to
# use this file, then the changes will become visible to X only if udev
# is restarted.  You may need to reboot the system.

I need to reboot? Seriously?

Any idea what changed my keyboard layout, and/or how can I prevent this from happening again? Why don't the KDE settings take precedence?

UPDATE:
This must have been some sort of freak occurrence. Some of KDE's keyboard shortcuts I had configured, weren't working either. Changing XKBLAYOUT to "uk", and rebooting changed everything back to normal.

Best Answer

The KDE keyboard layouts seemed to not work when kded was not running. Restarting the kdm service got it back up and running, but I'm not sure why it wasn't running in the first place... To kick-start kded without rebooting the whole system, log out of KDE, and log in to a Console Session. Then run:-

sudo service kdm restart

This can be done when logged into KDE, but you'll be automatically and abruptly logged out.

Related Question