We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This patch is a port of InstantWM's on_empty_keys. It allows you to configure key bindings for empty workspaces. Like so:
static const char* firefoxcmd[] = {"firefox", NULL}; static Key on_empty_keys[] = { /* modifier key function argument */ { 0, XK_f, spawn, {.v = firefoxcmd } }, };
patch:
diff --git a/config.def.h b/config.def.h index 1c0b587..2da2290 100644 --- a/config.def.h +++ b/config.def.h @@ -113,3 +113,9 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; +static const char* firefoxcmd[] = {"firefox", NULL}; +static Key on_empty_keys[] = { + /* modifier key function argument */ + { 0, XK_f, spawn, {.v = firefoxcmd } }, +}; + diff --git a/dwm.c b/dwm.c index 664c527..11bfaf0 100644 --- a/dwm.c +++ b/dwm.c @@ -141,6 +141,9 @@ typedef struct { int monitor; } Rule; + +static int isempty; + /* function declarations */ static void applyrules(Client *c); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); @@ -804,6 +807,16 @@ focus(Client *c) } selmon->sel = c; drawbars(); + + if (!c){ + if (!isempty) { + isempty = 1; + grabkeys(); + } + } else if (isempty) { + isempty = 0; + grabkeys(); + } } /* there are some broken focus acquiring clients needing extra handling */ @@ -961,6 +974,14 @@ grabkeys(void) for (j = 0; j < LENGTH(modifiers); j++) XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, True, GrabModeAsync, GrabModeAsync); + + if(!selmon->sel) { + for (i = 0; i < LENGTH(on_empty_keys); i++) + if ((code = XKeysymToKeycode(dpy, on_empty_keys[i].keysym))) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabKey(dpy, code, on_empty_keys[i].mod | modifiers[j], root, + True, GrabModeAsync, GrabModeAsync); + } } } @@ -997,6 +1018,13 @@ keypress(XEvent *e) && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func) keys[i].func(&(keys[i].arg)); + if(!selmon->sel) { + for (i = 0; i < LENGTH(on_empty_keys); i++) + if (keysym == on_empty_keys[i].keysym + && CLEANMASK(on_empty_keys[i].mod) == CLEANMASK(ev->state) + && on_empty_keys[i].func) + on_empty_keys[i].func(&(on_empty_keys[i].arg)); + } } void
The text was updated successfully, but these errors were encountered:
Adding on_empty_keys patch ref. #51
37c212a
Adding on_empty_keys patch ref. bakkeby#51
78bf598
No branches or pull requests
This patch is a port of InstantWM's on_empty_keys.
It allows you to configure key bindings for empty workspaces. Like so:
patch:
The text was updated successfully, but these errors were encountered: