aewl
view key.c @ 15:00d4d52b231f
removed unnecessary sel stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 18:19:01 +0200 |
parents | d567f430a81d |
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 static const char *term[] = {
11 "xterm", "-u8", "-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 | ShiftMask, XK_c, kill, NULL},
23 { Mod1Mask | ShiftMask, XK_q, quit, NULL},
24 };
26 void
27 update_keys()
28 {
29 unsigned int i, len;
30 KeyCode code;
32 len = sizeof(key) / sizeof(key[0]);
33 for(i = 0; i < len; i++) {
34 code = XKeysymToKeycode(dpy, key[i].keysym);
35 XUngrabKey(dpy, code, key[i].mod, root);
36 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
37 }
38 }
40 void
41 keypress(XEvent *e)
42 {
43 XKeyEvent *ev = &e->xkey;
44 unsigned int i, len;
45 KeySym keysym;
47 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
48 len = sizeof(key) / sizeof(key[0]);
49 for(i = 0; i < len; i++)
50 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
51 if(key[i].func)
52 key[i].func(key[i].aux);
53 return;
54 }
55 }