dwm-meillo

view kb.c @ 24:40b651a26a04

new colors
author Anselm R. Garbe <garbeam@wmii.de>
date Wed, 12 Jul 2006 00:50:09 +0200
parents 4560e0882c1d
children f96fb3fd8203
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 | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
17 };
19 static Key key[] = {
20 { Mod1Mask, XK_Return, run, term },
21 { Mod1Mask, XK_p, run, proglist },
22 { Mod1Mask, XK_k, sel, "prev"},
23 { Mod1Mask, XK_j, sel, "next"},
24 { Mod1Mask | ShiftMask, XK_c, kill, NULL},
25 { Mod1Mask | ShiftMask, XK_q, quit, NULL},
26 };
28 void
29 update_keys()
30 {
31 unsigned int i, len;
32 KeyCode code;
34 len = sizeof(key) / sizeof(key[0]);
35 for(i = 0; i < len; i++) {
36 code = XKeysymToKeycode(dpy, key[i].keysym);
37 XUngrabKey(dpy, code, key[i].mod, root);
38 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
39 }
40 }
42 void
43 keypress(XEvent *e)
44 {
45 XKeyEvent *ev = &e->xkey;
46 unsigned int i, len;
47 KeySym keysym;
49 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
50 len = sizeof(key) / sizeof(key[0]);
51 for(i = 0; i < len; i++)
52 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
53 if(key[i].func)
54 key[i].func(key[i].aux);
55 return;
56 }
57 }