Updated README.md, mwm.c.

This commit is contained in:
Luis Lavaire 2024-11-14 13:26:36 -06:00
parent 5e4007b9d1
commit b699198154
2 changed files with 7 additions and 8 deletions

View file

@ -2,19 +2,18 @@
For the true minimalist: For the true minimalist:
- ~20 LOC. - ~40 LOC.
- No default keybindings. - No default keybindings (just edit the source).
- No title bars, no status bars, no buttons, no borders, no menus, etc. - No title bars, no status bars, no buttons, no borders, no menus, etc.
- No mouse control. - No mouse control.
- No virtual desktops. - No virtual desktops.
- No configuration files. - No configuration files.
- Absolutely adabptable to your needs. - Absolutely adabptable to your needs.
- Includes just what is strictly needed. - Includes just what is strictly needed.
- Not standards compliant (because, honestly, who gives a fuck?).
`mwm` just loops through X key press events and lets you bind `mwm` just loops through X key press events and lets you bind
actions to key presses. It provides two macros: `grab` and `on`. actions to key presses. It provides two macros: `grab` and `K`.
You first `grab` the key (e.g.: `grab("Return", Mod4Mask)`), then you bind Read the source for an example on how to use it (my own setup).
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. Dead simple.

4
mwm.c
View file

@ -4,7 +4,7 @@
#define stk(s) XKeysymToKeycode(d, XStringToKeysym(s)) #define stk(s) XKeysymToKeycode(d, XStringToKeysym(s))
#define K(k, x) if (e.xkey.keycode == stk(k)) { x; } #define K(k, x) if (e.xkey.keycode == stk(k)) { x; }
#define E(_, x) if (e.type == _) { x; } #define E(_, x) if (e.type == _) { x; }
#define gks(...) const char *l[] = { __VA_ARGS__ }; \ #define grab(...) const char *l[] = { __VA_ARGS__ }; \
for (size_t i = 0; i < sizeof(l) / sizeof(*l); ++i) \ for (size_t i = 0; i < sizeof(l) / sizeof(*l); ++i) \
XGrabKey (d, stk(l[i]), Mod4Mask, r, 1, 1, 1); XGrabKey (d, stk(l[i]), Mod4Mask, r, 1, 1, 1);
@ -12,7 +12,7 @@ int main () {
Display *d = XOpenDisplay(0); Window r = DefaultRootWindow(d); XEvent e; Display *d = XOpenDisplay(0); Window r = DefaultRootWindow(d); XEvent e;
XSelectInput (d, r, SubstructureRedirectMask); XSelectInput (d, r, SubstructureRedirectMask);
gks ("q", "n", "l", "space", "Return", "Right", "Left", "Up", "Down"); grab ("q", "n", "l", "space", "Return", "Right", "Left", "Up", "Down");
while (!XNextEvent (d, &e)) { while (!XNextEvent (d, &e)) {
E (KeyPress, E (KeyPress,