aewl
view kb.c @ 31:386649deb651
before leaning things up
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Thu, 13 Jul 2006 01:04:38 +0200 |
parents | 8ad86d0a6a53 |
children | 082c75b937b5 |
line source
1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
6 #include "wm.h"
8 #include <X11/keysym.h>
10 /********** CUSTOMIZE **********/
12 char *cmdterm[] = {
13 "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
14 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
15 };
17 char *cmdproglist[] = {
18 "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
19 "| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
20 };
22 static Key key[] = {
23 { Mod1Mask, XK_Return, run, cmdterm },
24 { Mod1Mask, XK_p, run, cmdproglist},
25 { Mod1Mask, XK_k, sel, "prev" },
26 { Mod1Mask, XK_j, sel, "next" },
27 { Mod1Mask, XK_g, grid, NULL },
28 { Mod1Mask, XK_f, floating, NULL },
29 { Mod1Mask, XK_m, max, NULL },
30 { Mod1Mask | ShiftMask, XK_c, kill, NULL },
31 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
32 };
34 /********** CUSTOMIZE **********/
36 void
37 update_keys()
38 {
39 unsigned int i, len;
40 KeyCode code;
42 len = sizeof(key) / sizeof(key[0]);
43 for(i = 0; i < len; i++) {
44 code = XKeysymToKeycode(dpy, key[i].keysym);
45 XUngrabKey(dpy, code, key[i].mod, root);
46 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
47 }
48 }
50 void
51 keypress(XEvent *e)
52 {
53 XKeyEvent *ev = &e->xkey;
54 unsigned int i, len;
55 KeySym keysym;
57 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
58 len = sizeof(key) / sizeof(key[0]);
59 for(i = 0; i < len; i++)
60 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
61 if(key[i].func)
62 key[i].func(key[i].aux);
63 return;
64 }
65 }