How can I programmatically change the keyboard layout?

Posted by Jason R. Coombs on Ask Ubuntu See other posts from Ask Ubuntu or by Jason R. Coombs
Published on 2012-05-11T03:11:42Z Indexed on 2012/10/18 17:25 UTC
Read the original article Hit count: 272

Filed under:
|

I want to run a shell command or script that will configure each of my Ubuntu Precise boxes to use the Dvorak keyboard layout as the default (and only) layout. With earlier versions, I was able to set the XKBVARIANT in /etc/default/keyboard but when I make this change in Precise (and reboot), the keyboard layout appears to be unaffected (both in console and in gnome).

I tried also setting the XKBMODEL to pc105 and XKBLAYOUT to us, but that did not seem to help.

I know I can set the layout for gnome using the 'keyboard layout' tool... but I want the change to affect the console, and I want to automate the process. How can I accomplish this?

Edit:

To clarify, I want to know how I can cause to change (using only a script or command-line) the keyboard layout to be Dvorak as the default and only keyboard layout for both Gnome and the console. I want this change to be persistent (survive reboots), just as it is when the change is made through the Keyboard Layout tool.

Edit:

Let me put it another way. If I had installed the operating system myself (which I did not because the OS was installed by the virtual machine infrastructure), I could have selected the desired keyboard layout at install time, and that layout would be applied persistently, system-wide. How can I change the layout to appear as if I had set it during the install process?

© Ask Ubuntu or respective owner

Related posts about keyboard

Related posts about default