Created
January 3, 2013 00:14
-
-
Save c00kiemon5ter/4439626 to your computer and use it in GitHub Desktop.
the non window manager in 9 lines of code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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