how do I switch between qwerty & dvorak in console (TTY1 - TTY6)?

Asked by Joe

I want to be able to switch between the qwerty and dvorak keyboard layouts in the console interface, such as TTY1. I would prefer to have the dvorak layout by default when I log in, but have qwerty be the default for the other users in my household. Short of that, I want to be able to switch to dvorak after I log in.

I have not been able to get the dvorak keyboard layout at all in the console interface. What I've tried:
Ubuntu booted into the Gnome desktop. I pressed Ctrl-Alt-F1 to switch to TTY1. Then I logged in to TTY1.
I tried "loadkeys dvorak" and "loadkeys /usr/share/keymaps/i386/dvorak" and "loadkeys dvorak/dvorak" but that did not work (error: "keymapfile: no such file or directory"), probably because "/usr/share/keymaps/" is empty. I guess Ubuntu does not populate that folder.
I tried "setxkbmap dvorak" but got the error message, 'Cannot open display "default display"'. I got that message no matter what setxkbmap command I typed.

I do know how to change to and from dvorak in the Gnome desktop. I'm just asking how to do it in the console.

Thanks for any help.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
chantra
Solved:
Last query:
Last reply:
Revision history for this message
Best chantra (chantra) said :
#1

In order to get the layout install under /usr/share/keymaps/, you should install console-data
$ sudo apt-get install console-data
The installer should guide you through a wizard. If it is not the case, type:
$ sudo dpkg-reconfigure console-data

and choose your layout.

Revision history for this message
Joe (cowboyjo) said :
#2

Thanks very much. Your solution gives me a way to switch keyboards layouts in the console, and that is what I needed most. I'd still like to be able to have TTY1-TTY6 consoles use different user-specific layouts automatically after the user logs in, and I'd like to have a way to switch keyboards while in the consoles without requiring the superuser password - I'd appreciate any suggestions. I'll mark this as solved.

DETAILS OF WHAT I DID:
Per your suggestion, I ran the "sudo apt-get install console-data" command. The "Configuring console-data" interface did appear. I was unsure what the impact of the various “policies” would be (Would they permanently change the keyboard for all users? Would they change the keyboard layout that is in affect when any user logs in? Would they affect both the Gnome desktop and the TTY1-TTY6 consoles?), but I chose “Select keymap from arch list” and then “dvorak”.

RESULTS:
* /usr/share/keymaps/ was populated with more files and folders, including the dvorak layout files.
* “setxkbmap us” and “setxkbmap dvorak” worked in the Terminal window in the Gnome desktop, but not in TTY1. I'm guessing “setxkbmap” only works in x-windows-like interfaces.
* TTY1 still starts in qwerty layout, but “sudo loadkeys /usr/share/keymaps/i386/dvorak/dvorak.map.gz” and “sudo loadkeys /usr/share/keymaps/i386/qwerty/us.kmap.gz” worked in TTY1.
* If I set TTY1 to dvorak, and leave it that way when I log out, I need to use the dvorak layout as I log in again. But the qwerty layout was always active when logging in just after I re-booted, even though TTY1 was dvorak when I shut down. (The shut-down did hang, and I ended up pulling the power to turn off the computer. I don't know if the post-boot login would have used dvorak were the shut-down to have finished properly.)