Configuration of dwm for Mac Computers
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.

60 lines
1.4 KiB

18 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. static const char *term[] = {
  8. "xterm", "-bg", "black", "-fg", "white", "-fn",
  9. "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0
  10. };
  11. static const char *proglist[] = {
  12. "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
  13. "| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
  14. };
  15. static Key key[] = {
  16. { Mod1Mask, XK_Return, run, term },
  17. { Mod1Mask, XK_p, run, proglist },
  18. { Mod1Mask, XK_k, sel, "prev" },
  19. { Mod1Mask, XK_j, sel, "next" },
  20. { Mod1Mask, XK_g, arrange, NULL },
  21. { Mod1Mask, XK_m, max, NULL },
  22. { Mod1Mask | ShiftMask, XK_c, kill, NULL },
  23. { Mod1Mask | ShiftMask, XK_q, quit, NULL },
  24. };
  25. void
  26. update_keys()
  27. {
  28. unsigned int i, len;
  29. KeyCode code;
  30. len = sizeof(key) / sizeof(key[0]);
  31. for(i = 0; i < len; i++) {
  32. code = XKeysymToKeycode(dpy, key[i].keysym);
  33. XUngrabKey(dpy, code, key[i].mod, root);
  34. XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
  35. }
  36. }
  37. void
  38. keypress(XEvent *e)
  39. {
  40. XKeyEvent *ev = &e->xkey;
  41. unsigned int i, len;
  42. KeySym keysym;
  43. keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
  44. len = sizeof(key) / sizeof(key[0]);
  45. for(i = 0; i < len; i++)
  46. if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
  47. if(key[i].func)
  48. key[i].func(key[i].aux);
  49. return;
  50. }
  51. }