Skip to content

Instantly share code, notes, and snippets.

@c00kiemon5ter
Created January 3, 2013 00:14
Show Gist options
  • Save c00kiemon5ter/4439626 to your computer and use it in GitHub Desktop.
Save c00kiemon5ter/4439626 to your computer and use it in GitHub Desktop.
the non window manager in 9 lines of code
/* under cookie license -- all cookies (C) reserved
* contact c00kiemon5ter on freenode
*
* build
* -----
* make nwm CFLAGS="-std=c99 -Wall -Wextra -pedantic -Os -lX11" LDFLAGS="-s"
*
* usage
* -----
* setup your ~/.xinitrc and startx
* minimal ~/.xinitrc:
* xterm &
* exec /path/to/nwm
*
* to quit press Mod1+Q
*/
#include <X11/Xlib.h>
int main(void) {
Display *dpy = XOpenDisplay(NULL);
if (!dpy) return 1;
const KeyCode kc = XKeysymToKeycode(dpy, XStringToKeysym("Q"));
XGrabKey(dpy, kc, Mod1Mask, DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
for (XEvent ev; !XNextEvent(dpy, &ev) && !(ev.type == KeyPress && ev.xkey.keycode == kc););
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment