aewl

annotate kb.c @ 31:386649deb651

before leaning things up
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 01:04:38 +0200
parents 8ad86d0a6a53
children 082c75b937b5
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@31 10 /********** CUSTOMIZE **********/
garbeam@31 11
garbeam@31 12 char *cmdterm[] = {
garbeam@29 13 "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
garbeam@31 14 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
garbeam@14 15 };
garbeam@14 16
garbeam@31 17 char *cmdproglist[] = {
garbeam@27 18 "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
garbeam@27 19 "| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
garbeam@14 20 };
garbeam@14 21
garbeam@8 22 static Key key[] = {
garbeam@31 23 { Mod1Mask, XK_Return, run, cmdterm },
garbeam@31 24 { Mod1Mask, XK_p, run, cmdproglist},
garbeam@27 25 { Mod1Mask, XK_k, sel, "prev" },
garbeam@27 26 { Mod1Mask, XK_j, sel, "next" },
garbeam@31 27 { Mod1Mask, XK_g, grid, NULL },
garbeam@31 28 { Mod1Mask, XK_f, floating, NULL },
garbeam@28 29 { Mod1Mask, XK_m, max, NULL },
garbeam@27 30 { Mod1Mask | ShiftMask, XK_c, kill, NULL },
garbeam@27 31 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
garbeam@8 32 };
garbeam@8 33
garbeam@31 34 /********** CUSTOMIZE **********/
garbeam@31 35
garbeam@8 36 void
garbeam@8 37 update_keys()
garbeam@8 38 {
garbeam@8 39 unsigned int i, len;
garbeam@8 40 KeyCode code;
garbeam@8 41
garbeam@8 42 len = sizeof(key) / sizeof(key[0]);
garbeam@8 43 for(i = 0; i < len; i++) {
garbeam@8 44 code = XKeysymToKeycode(dpy, key[i].keysym);
garbeam@8 45 XUngrabKey(dpy, code, key[i].mod, root);
garbeam@8 46 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
garbeam@8 47 }
garbeam@8 48 }
garbeam@9 49
garbeam@9 50 void
garbeam@9 51 keypress(XEvent *e)
garbeam@9 52 {
garbeam@9 53 XKeyEvent *ev = &e->xkey;
garbeam@9 54 unsigned int i, len;
garbeam@9 55 KeySym keysym;
garbeam@9 56
garbeam@9 57 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
garbeam@9 58 len = sizeof(key) / sizeof(key[0]);
garbeam@9 59 for(i = 0; i < len; i++)
garbeam@9 60 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
garbeam@9 61 if(key[i].func)
garbeam@14 62 key[i].func(key[i].aux);
garbeam@9 63 return;
garbeam@9 64 }
garbeam@9 65 }