Re: [dev] surf - add missing keybinding

From: Kris Maglione <>
Date: Sun, 18 Oct 2009 17:09:53 -0400

On Sun, Oct 18, 2009 at 05:39:30PM +0200, Uriel wrote:
>On Sun, Oct 18, 2009 at 3:58 AM, Kris Maglione <> wrote:
>> But, I notice you don't have my nifty hack to make Xorg's compose behavior
>> the same as Plan 9's, so I still come out ahead. :)
>Ah, please tell me what is the hack! I'd love to add it to the page :)

Ok, but it's long-ish and ugly. And it uses python. I tried to
do it in awk, but it can't convert between characters and char
codes. You could just attach the result, but it's 95K
compressed, 650K otherwise. The upside, though, is that debian
people will be able to run it without installing
x11proto-core-dev. It would probably be easier to provide both.

First, we need to set Alt_R to the compose key. We could alter
the last step and skip this one, but this is the "correct" way
to do it:

     xmodmap -e 'keysym Alt_R = Multi_key'

Then we need to set some environment variables so GTK and QT
apps take note of our changes:


Finally, we need to setup $home/.XCompose and restart any
running apps:

python >$HOME/.XCompose <<!
import io
import os
import re

KEYSYMDEF = "/usr/include/X11/keysymdef.h"
KEYBOARD = "%s/lib/keyboard" % os.environ['PLAN9']
UNICODE = "%s/lib/unicode" % os.environ['PLAN9']
COMPOSE = "/usr/share/X11/locale/en_US.UTF-8/Compose"


f =, "r")
for line in f:
     match ='XK_(\S+).*0x+([0-9a-fA-F]+)', line)
     if match:
         KEYSYMS[int(, 16)] =

def write(seq, char, desc):
     print (u'<Multi_key> %- 30s : "%s" U%04X # %s' % (
             ' '.join('<%s>' % KEYSYMS.get(ord(c), c) for c in seq),
             char, ord(char), desc.upper())).encode('UTF-8')

print 'include "%s"\n' % COMPOSE
for line in, "r"):
     for seq in line[6:18].split():
         write(seq, line[18], line[20:-1])
print ''
for line in
     codepoint, desc = line.rstrip().split('\t', 2)
     write('X' + codepoint, unichr(int(codepoint, 16)), desc)

This gets us everything in /lib/keyboard, as well as Alt X0000
style mappings. If you want to skip the xmodmap step, just
change Multi_key above to Alt_R, but in that case, standard X11
compose sequences won't work as expected.

Kris Maglione
Religion began when the first scoundrel met the first fool.
Received on Sun Oct 18 2009 - 21:09:53 UTC

This archive was generated by hypermail 2.2.0 : Sun Oct 18 2009 - 21:12:02 UTC