dwm-meillo
view kb.c @ 27:f96fb3fd8203
added grid mode on Mod1Mask g
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Wed, 12 Jul 2006 16:00:51 +0200 |
parents | 95ffdfd0a819 |
children | 3dceb132082d |
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 "xterm", "-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 | ShiftMask, XK_c, kill, NULL },
27 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
28 };
30 void
31 update_keys()
32 {
33 unsigned int i, len;
34 KeyCode code;
36 len = sizeof(key) / sizeof(key[0]);
37 for(i = 0; i < len; i++) {
38 code = XKeysymToKeycode(dpy, key[i].keysym);
39 XUngrabKey(dpy, code, key[i].mod, root);
40 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
41 }
42 }
44 void
45 keypress(XEvent *e)
46 {
47 XKeyEvent *ev = &e->xkey;
48 unsigned int i, len;
49 KeySym keysym;
51 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
52 len = sizeof(key) / sizeof(key[0]);
53 for(i = 0; i < len; i++)
54 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
55 if(key[i].func)
56 key[i].func(key[i].aux);
57 return;
58 }
59 }