Scripting

Keyboard Setup For Dvorak

Using xmodmap to change layouts.

The dvorak key layouts in xmodmap are based on a US rather than UK physical keyboard.

This means that the \| key next to the L-Shift is <> and the #~ key next to the return key is mapped to \|.

Also, you will have to set up gnome, fluxbox etc individually to allow a keymap swap.

Here is how to switch keyboards easily and reconfigure the keys so that 3£ the \| and the #~ work correctly for a UK/GB keyboard.

Create a file /usr/bin/asdf with the following contents :


#!/bin/bash
xmodmap /usr/share/xmodmap/xmodmap.dvorak
xmodmap -e "keycode 12 = 3 sterling"
xmodmap -e "keycode 94 = backslash bar"
#This one corrects the numeric keypad . character not working
xmodmap -e "keycode 91 = KP_Decimal KP_Delete"
xmodmap -e "keycode 51 = numbersign asciitilde"
#These correct the Terminal switching not working properly - you may not need them.
xmodmap -e "keycode 67 = F1 XF86_Switch_VT_1"
xmodmap -e "keycode 68 = F2 XF86_Switch_VT_2"
xmodmap -e "keycode 69 = F3 XF86_Switch_VT_3"
xmodmap -e "keycode 70 = F4 XF86_Switch_VT_4"
xmodmap -e "keycode 71 = F5 XF86_Switch_VT_5"
xmodmap -e "keycode 72 = F6 XF86_Switch_VT_6"
xmodmap -e "keycode 73 = F7 XF86_Switch_VT_7"
xmodmap -e "keycode 74 = F8 XF86_Switch_VT_8"
xmodmap -e "keycode 75 = F9 XF86_Switch_VT_9"
xmodmap -e "keycode 76 = F10 XF86_Switch_VT_10"



Create another file /usr/bin/aoeu with the contents :

#!/bin/bash
xmodmap /usr/share/xmodmap/xmodmap.uk

Alter permissions to make them executable.

# chmod +x /usr/bin/aoeu
# chmod +x /usr/bin/asdf

Then, you can switch between keyboards by typing aoeu or asdf in a terminal or in the run application applet.

Setting up Keymaps for Gnome/KDE to make a UK keyboard work the same as the Windows dvorak keyboard

(except for the # is swapped with £ on the 3 key)

vi /usr/share/X11/xkb/symbols/gb

At the bottom, the dvorak section should look like :

// Dvorak (UK) keymap (by odaen) allowing the usage of
// the £ and ? key and swapping the @ and " keys.

partial alphanumeric_keys
xkb_symbols "dvorak" {
include "us(dvorak)"

name[Group1]="United Kingdom - Dvorak";

key <BKSL> { [ numbersign, asciitilde ] };
key <AE02> { [ 2, at, twosuperior, NoSymbol ] };
// key <AE02> { [ 2, quotedbl, twosuperior, NoSymbol ] };
key <AE03> { [ 3, sterling, threesuperior, NoSymbol ] };
key <AE04> { [ 4, dollar, EuroSign, NoSymbol ] };
key <LSGT> { [ backslash, bar ] };
key <AD01> { [ apostrophe, quotedbl ] };
// key <AD01> { [ apostrophe, at ] };
};

This prevents swapping of the \| and #~ keys. It also keeps the US mapping of the '" and 2@ keys as I am used to these from using the US-only dvorak keyboard in windows.

You can replicate the aoeu and asdf file tricks above for easy non-mouse switching. To do this,

asdf file just has :

#!/bin/bash
setxkbmap gb -variant dvorak

aoeu file just has :

#!/bin/bash
setxkbmap gb

Alter permissions to make them executable.

# chmod +x /usr/bin/aoeu
# chmod +x /usr/bin/asdf

Or just as one long thing to cut and paste:

if ! [ -d ~/bin ]; then
mkdir ~/bin
export PATH="~/bin:$PATH"
fi

cat > ~/bin/aoeu <<EOF
#!/bin/bash
setxkbmap gb
EOF

cat > ~/bin/asdf <<EOF
#!/bin/bash
setxkbmap gb -variant dvorak
EOF

chmod +x ~/bin/aoeu
chmod +x ~/bin/asdf

echo 'use the command "aoeu" to switch to uk'
echo 'use the command "asdf" to switch to dvorak'
echo 'done.'