dwm-meillo
view kb.c @ 30:2e0fb4130bfb
new stuff, fixed several issues
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Wed, 12 Jul 2006 17:50:31 +0200 |
parents | 3dceb132082d |
children | 386649deb651 |
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 static const char *term[] = {
11 "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
12 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0
13 };
15 static const char *proglist[] = {
16 "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
17 "| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
18 };
20 static Key key[] = {
21 { Mod1Mask, XK_Return, run, term },
22 { Mod1Mask, XK_p, run, proglist },
23 { Mod1Mask, XK_k, sel, "prev" },
24 { Mod1Mask, XK_j, sel, "next" },
25 { Mod1Mask, XK_g, arrange, NULL },
26 { Mod1Mask, XK_m, max, NULL },
27 { Mod1Mask | ShiftMask, XK_c, kill, NULL },
28 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
29 };
31 void
32 update_keys()
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 }