aewl

view kb.c @ 35:93c7c58a0891

renamed/changed
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 09:33:26 +0200
parents e90449e03167
children
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 const char *term[] = {
13 "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
14 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
15 };
16 const char *browse[] = { "firefox", NULL };
18 static Key key[] = {
19 { Mod1Mask, XK_Return, (void (*)(void *))spawn, term },
20 { Mod1Mask, XK_w, (void (*)(void *))spawn, browse },
21 { Mod1Mask, XK_k, sel, "prev" },
22 { Mod1Mask, XK_j, sel, "next" },
23 { Mod1Mask, XK_space, toggle, NULL },
24 { Mod1Mask, XK_m, max, NULL },
25 { Mod1Mask | ShiftMask, XK_c, ckill, NULL },
26 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
27 };
29 /********** CUSTOMIZE **********/
31 void
32 update_keys(void)
33 {
34 unsigned int i, len;
35 KeyCode code;
37 len = sizeof(key) / sizeof(key[0]);
38 for(i = 0; i < len; i++) {
39 code = XKeysymToKeycode(dpy, key[i].keysym);
40 XUngrabKey(dpy, code, key[i].mod, root);
41 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
42 }
43 }
45 void
46 keypress(XEvent *e)
47 {
48 XKeyEvent *ev = &e->xkey;
49 unsigned int i, len;
50 KeySym keysym;
52 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
53 len = sizeof(key) / sizeof(key[0]);
54 for(i = 0; i < len; i++)
55 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
56 if(key[i].func)
57 key[i].func(key[i].aux);
58 return;
59 }
60 }