Added main program, updated README.md

This commit is contained in:
Luis Lavaire 2024-01-08 02:59:57 -06:00
parent 31c9dbf6d5
commit d4d54307ce
2 changed files with 37 additions and 1 deletions

View file

@ -1,2 +1,20 @@
# mwm
MAYBE a window manager.
For the true minimalist:
- ~20 LOC.
- No default keybindings.
- No title bars, no status bars, no buttons, no borders, no menus, etc.
- No mouse control.
- No virtual desktops.
- No configuration files.
- Absolutely adabptable to your needs.
- Includes just what is strictly needed.
`mwm` just loops through X key press events and lets you bind
actions to key presses. It provides two macros: `grab` and `on`.
You first `grab` the key (e.g.: `grab("Return", Mod4Mask)`), then you bind
an action to it (e.g.: `on("Return", system("xterm &"))`). More than
one action can be provided (e.g.: `on("Tab", XCirculateSubwindowsUp(d, r); XSetInputFocus(d, e.xkey.window, 0, 0)))`).
Dead simple.

18
mwm.c Normal file
View file

@ -0,0 +1,18 @@
#include <X11/Xlib.h>
#define stok(s) XKeysymToKeycode(d, XStringToKeysym(s))
#define on(k, a) if (e.xkey.keycode == stok(k)) { a; continue; }
#define grab(k, m) XGrabKey (d, stok(k), m, r, 1, 1, 1)
int main (int argc, char **argv) {
Display *d = XOpenDisplay(0); Window r = DefaultRootWindow(d); XEvent e;
XSelectInput (d, r, SubstructureRedirectMask);
grab ("KEY", MODIFIER);
while (!XNextEvent (d, &e)) {
if (e.type == KeyPress) {
on (KEY, ACTIONS);
}
}
}