From d4d54307ce805b07bba7c2c482a91cf1c9df8251 Mon Sep 17 00:00:00 2001 From: Luis Lavaire Date: Mon, 8 Jan 2024 02:59:57 -0600 Subject: [PATCH] Added main program, updated README.md --- README.md | 20 +++++++++++++++++++- mwm.c | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 mwm.c diff --git a/README.md b/README.md index aba0f9b..25397d6 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/mwm.c b/mwm.c new file mode 100644 index 0000000..a382e7c --- /dev/null +++ b/mwm.c @@ -0,0 +1,18 @@ +#include + +#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); + } + } +}