[PLUG] Switching keyboard layouts via script

Rich Shepard rshepard at appl-ecosys.com
Thu Feb 25 17:28:14 UTC 2010


On Thu, 25 Feb 2010, Andrew Brookins wrote:

> Annnyway, does anyone have some wisdom on the best way to change my layout
> settings with a script?  Note that I'm not trying to change layouts --
> Gnome doesn't seem to store settings like Alt and Caps key swapping on a
> per layout basis.

Andrew,

   I've always liked the ctrl key to be at the left end of the home key line
since 1) that's where it was way back when microcomputer keyboards first
came out and b) I use that much more frequently than I do the capslock key.
(The latter is good only for the name of a character in John Sandford
novels: Del Capslock.)

   So, ... at the end of ~/.bash_profile I have:

loadkeys ~/.keymap

and ~/.keymap contains:

# Created 12 July 2002 by Rich Shepard
#
# Exchange the left Control key and the Caps Lock key on the keyboard
keymaps 0-2,4-6,8-9,12
keycode 58 = Control
keycode 29 = Caps_Lock

   This works well for console mode. Then, when I'm working in X, in
~/.xinitrc is the line:

$HOME/.Xmodmap && xmodmap $HOME/.Xmodmap

where .Xmodmap contains:

clear mod4
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
keysym Alt_L = Meta_L Alt_L

   Both the above have worked well for me for years, regardless of keyboard
used. Currently, my keyboard is a mini (same size as on my notebook) from
Fry's for $15. Takes little room and is highly efficient.

HTH,

Rich



More information about the PLUG mailing list