sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-bulkill-systray-safe-20231029-9f88553.diff (2732B)


      1 From 754f493ef44d4a0f7b59e8c95e50b911631ac60b Mon Sep 17 00:00:00 2001
      2 From: ysl2 <www.songli.yu@gmail.com>
      3 Date: Sun, 29 Oct 2023 15:40:44 +0800
      4 Subject: [PATCH] Bulk kill: arg.ui == 0 for normal kill current client; arg.ui
      5  == 1 for kill other clients in current tag (except current focusing client);
      6  arg.ui == 2 for kill all clients in current tag (include focusing client).
      7 
      8 ---
      9  bulkill.c    | 36 ++++++++++++++++++++++++++++++++++++
     10  config.def.h |  3 +++
     11  2 files changed, 39 insertions(+)
     12  create mode 100644 bulkill.c
     13 
     14 diff --git a/bulkill.c b/bulkill.c
     15 new file mode 100644
     16 index 0000000..c73958f
     17 --- /dev/null
     18 +++ b/bulkill.c
     19 @@ -0,0 +1,36 @@
     20 +static void killthis(Window w);
     21 +static void bulkill(const Arg *arg);
     22 +
     23 +void
     24 +killthis(Window w) {
     25 +	if (!sendevent(w, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) {
     26 +		XGrabServer(dpy);
     27 +		XSetErrorHandler(xerrordummy);
     28 +		XSetCloseDownMode(dpy, DestroyAll);
     29 +		XKillClient(dpy, w);
     30 +		XSync(dpy, False);
     31 +		XSetErrorHandler(xerror);
     32 +		XUngrabServer(dpy);
     33 +	}
     34 +}
     35 +
     36 +void
     37 +bulkill(const Arg *arg)
     38 +{
     39 +    Client *c;
     40 +
     41 +	if (!selmon->sel)
     42 +		return;
     43 +
     44 +    if (!arg->ui || arg->ui == 0) {
     45 +        killthis(selmon->sel->win);
     46 +        return;
     47 +    }
     48 +
     49 +    for (c = selmon->clients; c; c = c->next) {
     50 +        if (!ISVISIBLE(c) || (arg->ui == 1 && c == selmon->sel))
     51 +            continue;
     52 +        killthis(c->win);
     53 +    }
     54 +}
     55 +
     56 diff --git a/config.def.h b/config.def.h
     57 index 750529d..4d4bcef 100644
     58 --- a/config.def.h
     59 +++ b/config.def.h
     60 @@ -65,6 +65,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
     61  static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
     62  static const char *termcmd[]  = { "st", NULL };
     63  
     64 +#include "bulkill.c"
     65  static const Key keys[] = {
     66  	/* modifier                     key        function        argument */
     67  	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
     68 @@ -79,6 +80,8 @@ static const Key keys[] = {
     69  	{ MODKEY,                       XK_Return, zoom,           {0} },
     70  	{ MODKEY,                       XK_Tab,    view,           {0} },
     71  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     72 +    { MODKEY|ControlMask,           XK_c,      bulkill,        {.ui = 1} },  // kill unselect
     73 +    { MODKEY|ShiftMask|ControlMask, XK_c,      bulkill,        {.ui = 2} },  // killall
     74  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     75  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     76  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     77 -- 
     78 2.20.1
     79