You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.5 KiB

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