Very neat. Is it Ok if I post this to http://ninetimes.cat-v.org/tips/ ?
Thanks!
uriel
On Sun, Oct 18, 2009 at 11:09 PM, Kris Maglione <maglione.k_AT_gmail.com> wrote:
> On Sun, Oct 18, 2009 at 05:39:30PM +0200, Uriel wrote:
>>
>> On Sun, Oct 18, 2009 at 3:58 AM, Kris Maglione <maglione.k_AT_gmail.com>
>> 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:
>
> Â Â GTK_IM_MODULE=xim
> Â Â QT_IM_MODULE=xim
>
> 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"
>
> KEYSYMS = {}
>
> f = io.open(KEYSYMDEF, "r")
> for line in f:
> Â Â match = re.search(r'XK_(\S+).*0x+([0-9a-fA-F]+)', line)
> Â Â if match:
> Â Â Â Â KEYSYMS[int(match.group(2), 16)] = match.group(1)
>
> 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 io.open(KEYBOARD, "r"):
> Â Â for seq in line[6:18].split():
> Â Â Â Â write(seq, line[18], line[20:-1])
> print ''
> for line in io.open(UNICODE):
> Â Â 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.
> Â Â Â Â --Voltaire
>
>
>
Received on Mon Oct 19 2009 - 15:45:01 UTC
This archive was generated by hypermail 2.2.0 : Mon Oct 19 2009 - 15:48:02 UTC