Updated mwm.c.
This commit is contained in:
parent
1e11c98aad
commit
5e4007b9d1
1 changed files with 27 additions and 7 deletions
34
mwm.c
34
mwm.c
|
|
@ -1,17 +1,37 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <stdlib.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)
|
||||
#define stk(s) XKeysymToKeycode(d, XStringToKeysym(s))
|
||||
#define K(k, x) if (e.xkey.keycode == stk(k)) { x; }
|
||||
#define E(_, x) if (e.type == _) { x; }
|
||||
#define gks(...) const char *l[] = { __VA_ARGS__ }; \
|
||||
for (size_t i = 0; i < sizeof(l) / sizeof(*l); ++i) \
|
||||
XGrabKey (d, stk(l[i]), Mod4Mask, r, 1, 1, 1);
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int main () {
|
||||
Display *d = XOpenDisplay(0); Window r = DefaultRootWindow(d); XEvent e;
|
||||
XSelectInput (d, r, SubstructureRedirectMask);
|
||||
|
||||
// grab keys here.
|
||||
gks ("q", "n", "l", "space", "Return", "Right", "Left", "Up", "Down");
|
||||
|
||||
while (!XNextEvent (d, &e)) {
|
||||
if (e.type == KeyPress) ;
|
||||
// define actions here.
|
||||
E (KeyPress,
|
||||
K("n", XCirculateSubwindowsUp(d, r); XSetInputFocus(d, e.xkey.window, 2, 0))
|
||||
K("q", XKillClient(d, e.xkey.subwindow))
|
||||
K("l", system("rotK &"))
|
||||
K("space", system("chromium &"))
|
||||
K("Return", system("xterm &"))
|
||||
K("Right", system("vol 5%+ &"))
|
||||
K("Left", system("vol 5%- &"))
|
||||
K("Up", system("bri +100 &"))
|
||||
K("Down", system("bri -100 &")))
|
||||
|
||||
E (MapRequest,
|
||||
XMapWindow(d, e.xmaprequest.window);
|
||||
XSetInputFocus(d, e.xmaprequest.window, 2, 0))
|
||||
|
||||
E (ConfigureRequest,
|
||||
XMoveResizeWindow (d, e.xconfigure.window, 0, 0, e.xconfigure.width, e.xconfigure.height);
|
||||
XMoveResizeWindow (d, e.xconfigure.window, 0, 0, 1920, 1080))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue