Path: utzoo!mnetor!uunet!husc6!bloom-beacon!athena.mit.edu!jtkohl From: jtkohl@athena.mit.edu (John T Kohl) Newsgroups: comp.windows.x Subject: Re: Key mapping Message-ID: <2644@bloom-beacon.MIT.EDU> Date: 29 Jan 88 14:56:54 GMT References: <8801290235.AA20303@violet.berkeley.edu> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: jtkohl@athena.mit.edu (John T Kohl) Organization: Massachusetts Institute of Technology Lines: 62 In article <8801290235.AA20303@violet.berkeley.edu> jkh@VIOLET.BERKELEY.EDU (Jordan K. Hubbard) writes: >Has anyone written a utility for mapping keys around in >a relatively painless way? For instance, I'd like to get my "F1" >key on the LK201 (microvax) keyboard to be escape, but there doesn't >seem to be any easy way to do it. Here is a (relatively gross) program to do what you want. I haven't posted it before since I thought I would eventually find a way to use XRebindKeysym, but my attempts to use it failed. See sections 7.9 and 10.1 of Xlib manual for more info. to use the program, you give it pairs of args to be rebound, like so: xkbdmap F1 Escape F9 Escape which redefines F1 and F9 to be Escape keys. This is NOT idempotent and irreversible. (more reasons not to release this, but you asked.... :-) Enjoy. Compile by cc -o xkbdmap xkbdmap.c -lX11 ---------------------xkbdmap.c------------ #include #include #include #include #include main(argc, argv) int argc; char **argv; { KeySym old, new; int old_code; Display *dpy; if (!(dpy = XOpenDisplay(getenv("DISPLAY")))) { fprintf(stderr,"Cannot open display '%s'\n",getenv("DISPLAY")); exit(1); } argv++, argc--; if (argc & 0x1) { fprintf(stderr,"must use even # args\n"); exit(1); } while (argc > 1) { old = XStringToKeysym(*argv++); new = XStringToKeysym(*argv++); argc--, argc--; old_code = XKeysymToKeycode(dpy, old); XChangeKeyboardMapping(dpy, old_code, 1, &new, 1); } XFlush(dpy); XCloseDisplay(dpy); exit(0); } ---------------end kbdmap.c--------------------- ---- John Kohl MIT/Project Athena