diff --git a/README.md b/README.md index 05ba782..bf12fa0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2019-10-05 - Added killunsel patch + 2019-10-04 - Added maximize, movestack, monoclesymbol, noborder, tagall and tagintostack patches 2019-10-03 - Added onlyquitonempty and switchcol patches @@ -222,6 +224,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [unfloatvisible](https://dwm.suckless.org/patches/unfloatvisible/) - resets isfloating on any visible windows that have it set and optionally also applies a layout + - [killunsel](https://dwm.suckless.org/patches/killunsel/) + - kills all visible clients that are not selected (only the selected client will remain) + - [urgentborder](https://dwm.suckless.org/patches/urgentborder/) - this patch makes "urgent" windows have different colors diff --git a/config.def.h b/config.def.h index 5640b51..ec350fc 100644 --- a/config.def.h +++ b/config.def.h @@ -364,6 +364,9 @@ static Key keys[] = { { MODKEY, XK_z, showhideclient, {0} }, #endif // AWESOMEBAR_PATCH { MODKEY|ShiftMask, XK_c, killclient, {0} }, + #if KILLUNSEL_PATCH + { MODKEY|ShiftMask, XK_x, killunsel, {0} }, + #endif // KILLUNSEL_PATCH #if SELFRESTART_PATCH { MODKEY|ShiftMask, XK_r, self_restart, {0} }, #endif // SELFRESTART_PATCH diff --git a/patch/include.c b/patch/include.c index 714e4b4..204f2d8 100644 --- a/patch/include.c +++ b/patch/include.c @@ -52,6 +52,10 @@ #include "holdbar.c" #endif +#if KILLUNSEL_PATCH +#include "killunsel.c" +#endif + #if MAXIMIZE_PATCH #include "maximize.c" #endif diff --git a/patch/include.h b/patch/include.h index 1cae911..38f5485 100644 --- a/patch/include.h +++ b/patch/include.h @@ -52,6 +52,10 @@ #include "holdbar.h" #endif +#if KILLUNSEL_PATCH +#include "killunsel.h" +#endif + #if MAXIMIZE_PATCH #include "maximize.h" #endif diff --git a/patch/killunsel.c b/patch/killunsel.c new file mode 100644 index 0000000..9e06d53 --- /dev/null +++ b/patch/killunsel.c @@ -0,0 +1,22 @@ +void +killunsel(const Arg *arg) +{ + Client *i = NULL; + + if (!selmon->sel) + return; + + for (i = selmon->clients; i; i = i->next) { + if (ISVISIBLE(i) && i != selmon->sel) { + if (!sendevent(i, wmatom[WMDelete])) { + XGrabServer(dpy); + XSetErrorHandler(xerrordummy); + XSetCloseDownMode(dpy, DestroyAll); + XKillClient(dpy, i->win); + XSync(dpy, False); + XSetErrorHandler(xerror); + XUngrabServer(dpy); + } + } + } +} \ No newline at end of file diff --git a/patch/killunsel.h b/patch/killunsel.h new file mode 100644 index 0000000..4f38a6e --- /dev/null +++ b/patch/killunsel.h @@ -0,0 +1 @@ +static void killunsel(const Arg *arg); \ No newline at end of file diff --git a/patches.h b/patches.h index d7a0642..9bd770a 100644 --- a/patches.h +++ b/patches.h @@ -175,6 +175,11 @@ */ #define HOLDBAR_PATCH 0 +/* This patch adds a keybinding to kills all visible clients that are not selected. + * https://dwm.suckless.org/patches/killunsel/ + */ +#define KILLUNSEL_PATCH 0 + /* Moves the layout symbol in the status bar to the left hand side. * http://dwm.suckless.org/patches/leftlayout/ */