rev |
line source |
garbeam@8
|
1 /*
|
garbeam@8
|
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
garbeam@8
|
3 * See LICENSE file for license details.
|
garbeam@8
|
4 */
|
garbeam@8
|
5
|
garbeam@8
|
6 #include "wm.h"
|
garbeam@8
|
7
|
garbeam@8
|
8 #include <X11/keysym.h>
|
garbeam@8
|
9
|
garbeam@14
|
10 static const char *term[] = {
|
garbeam@20
|
11 "xterm", "-bg", "black", "-fg", "white", "-fn",
|
garbeam@14
|
12 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0
|
garbeam@14
|
13 };
|
garbeam@14
|
14
|
garbeam@14
|
15 static const char *proglist[] = {
|
garbeam@27
|
16 "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
|
garbeam@27
|
17 "| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
|
garbeam@14
|
18 };
|
garbeam@14
|
19
|
garbeam@8
|
20 static Key key[] = {
|
garbeam@14
|
21 { Mod1Mask, XK_Return, run, term },
|
garbeam@14
|
22 { Mod1Mask, XK_p, run, proglist },
|
garbeam@27
|
23 { Mod1Mask, XK_k, sel, "prev" },
|
garbeam@27
|
24 { Mod1Mask, XK_j, sel, "next" },
|
garbeam@27
|
25 { Mod1Mask, XK_g, arrange, NULL },
|
garbeam@27
|
26 { Mod1Mask | ShiftMask, XK_c, kill, NULL },
|
garbeam@27
|
27 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
|
garbeam@8
|
28 };
|
garbeam@8
|
29
|
garbeam@8
|
30 void
|
garbeam@8
|
31 update_keys()
|
garbeam@8
|
32 {
|
garbeam@8
|
33 unsigned int i, len;
|
garbeam@8
|
34 KeyCode code;
|
garbeam@8
|
35
|
garbeam@8
|
36 len = sizeof(key) / sizeof(key[0]);
|
garbeam@8
|
37 for(i = 0; i < len; i++) {
|
garbeam@8
|
38 code = XKeysymToKeycode(dpy, key[i].keysym);
|
garbeam@8
|
39 XUngrabKey(dpy, code, key[i].mod, root);
|
garbeam@8
|
40 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
|
garbeam@8
|
41 }
|
garbeam@8
|
42 }
|
garbeam@9
|
43
|
garbeam@9
|
44 void
|
garbeam@9
|
45 keypress(XEvent *e)
|
garbeam@9
|
46 {
|
garbeam@9
|
47 XKeyEvent *ev = &e->xkey;
|
garbeam@9
|
48 unsigned int i, len;
|
garbeam@9
|
49 KeySym keysym;
|
garbeam@9
|
50
|
garbeam@9
|
51 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
garbeam@9
|
52 len = sizeof(key) / sizeof(key[0]);
|
garbeam@9
|
53 for(i = 0; i < len; i++)
|
garbeam@9
|
54 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
|
garbeam@9
|
55 if(key[i].func)
|
garbeam@14
|
56 key[i].func(key[i].aux);
|
garbeam@9
|
57 return;
|
garbeam@9
|
58 }
|
garbeam@9
|
59 }
|