Matthew Rosewarne on 30 Nov 2007 23:42:23 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Follow-Up: Entering extended characters in Linux


So, after some experimentation, I've come up with quite a nice setup.  This
might be useful to others looking to unleash the potential of that unassuming
plastic board in front of the screen.


Snippet of /etx/X11/xorg.conf:

	Section	"InputDevice"
		Identifier	"Generic Keyboard"
		Driver		"kbd"
		Option		"CoreKeyboard"
		Option		"XkbRules"	"xorg"
		Option		"XkbModel"	"pc104"
		Option		"XkbLayout"	"en_US,us"
		Option		"XkbVariant"	",colemak"
		Option		"XkbOptions"	"grp:sclk_toggle,grp_led:scroll,lv3:ralt_alt,keypad:oss,nbsp:level3n"
	EndSection

What's it do?  Well, it:
	* Sets the keyboard type to pc104, the usual keyboard with "Windows" keys
	* Defines two keyboard layouts (comma-separated), for different locales:
		1. The usual US layout, but with a "level 3 shift" that allows entering
		    various non-ASCII characters
		2. The regular US layout
	* Defines keyboard "variants" for the each of the two layouts
	   (comma-separated, same order as layouts):
		1. No variant, plain old QWERTY
		2. COLEMAK variant, COLEMAK is an alternative keyboard scheme that is
		    supposedly faster & easier than DVORAK
			- COLEMAK only works with the "us" layout, not "en_US", but provides its
			   own "level 3" keys
	* Sets various options:
		1. Scroll Lock is pointless, so make the Scroll Lock key instead switch 
		    between QWERTY and COLEMAK layouts.
		2. When using COLEMAK, turn on the Scroll Lock LED.
		3. When using a layout with "level 3 shift", the right-Alt key is the 
		    default "level 3 shift" key.  I'd prefer to leave Right-Alt as Right-Alt 
		    and set another key to be "level 3 shift" with xmodmap.
		4. Make some extra math symbols available on the keypad in "level 3 shift"
		5. Make the spacebar type a non-breaking-space in "level 3", and a
		    non-breaking-thin-space in shift+"level 3"

If just I wanted to apply this setup to my current X session instead of the
whole system, I could run the command:
	setxkbmap -model pc104 -layout "en_US,us" -variant ",colemak" \
	-option "grp:sclk_toggle" -option "grp_led:scroll" -option "lv3:ralt_alt" \
	-option "keypad:oss" -option "nbsp:level3n"


In addition to these settings, I set a few things with xmodmap by putting some
xmodmap commands in a file called ~/.xmodmaprc:
	!
	! Caps Lock is Level 3 shift
	!
	remove Lock = Caps_Lock
	keysym Caps_Lock = ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift
	
	!
	! Pause/Break is Compose
	!
	keysym Pause = Multi_key

I chose the Caps Lock key to be my "level 3 shift" because I never use it, and
it's right above shift.  When shift and "level 3 shift" are pressed together,
even more characters are available.  I needed to specify "ISO_Level3_Shift"
four times so it would work in both QWERTY and COLEMAK modes, but for some
reason I didn't need to do that for "Multi_key".

Pause/Break is also a pointless key.  I might as well have it do something 
useful, so I set it to be the "Compose" key.

In order for X to actually make use of ~/.xmodmaprc, I put the
file "40custom_load-xmodmap" in "/etc/X11/Xsession.d/", which looks like:
	SYSMODMAP="/etc/X11/Xmodmap"
	USRMODMAP="$HOME/.xmodmaprc"
	
	if which xmodmap > /dev/null; then
	    if [ -f "$SYSMODMAP" ]; then
	        xmodmap "$SYSMODMAP"
	    fi
	    if [ -f "$USRMODMAP" ]; then
	        xmodmap "$USRMODMAP"
	    fi
	fi


That's all well-and-good, but how do I know what these "level 3" characters
are, and how to I figure out what the COLEMAK keys are?
I can generate a PostScript picture of the keyboard showing what it will type
when it's in "level 3":
	xkbprint -color -ll 3 $DISPLAY
I can generate another picture of the keyboard in COLEMAK mode:
	xkbprint -color -lg 2 $DISPLAY
And another of what I can type in COLEMAK's "level 3"
	xkbprint -color -lg 2 -ll 3 $DISPLAY


So what does all this do for me?
	* I can use the Caps Lock key to allow me to type various non-ASCII
	   characters, and even more with Shift+Caps Lock
	* I can use the Pause/Break key as the Compose key to type all sorts of
	   strange characters
	* I can use the Scroll Lock key to switch between QWERTY and COLEMAK
	* If the keyboard is set to COLEMAK, the Scroll Lock LED lights up
	* I still have all of my other useful keys (left/right Alt,
	   left/right "WindowsÂkey", "Menu Key")
	* I have nice "cheat sheet" pages to help me find the "level 3" characters
	   and learn the COLEMAK keys

Attachment: signature.asc
Description: This is a digitally signed message part.

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug