sites

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

dwm-allowkillrule-6.4.diff (3700B)


      1 diff -up a/config.def.h b/config.def.h
      2 --- a/config.def.h	2022-10-04 19:38:18.000000000 +0200
      3 +++ b/config.def.h	2023-05-06 22:19:27.298742237 +0200
      4 @@ -5,6 +5,7 @@ static const unsigned int borderpx  = 1;
      5  static const unsigned int snap      = 32;       /* snap pixel */
      6  static const int showbar            = 1;        /* 0 means no bar */
      7  static const int topbar             = 1;        /* 0 means bottom bar */
      8 +static const int allowkill          = 1;        /* allow killing clients by default? */
      9  static const char *fonts[]          = { "monospace:size=10" };
     10  static const char dmenufont[]       = "monospace:size=10";
     11  static const char col_gray1[]       = "#222222";
     12 @@ -26,9 +27,9 @@ static const Rule rules[] = {
     13  	 *	WM_CLASS(STRING) = instance, class
     14  	 *	WM_NAME(STRING) = title
     15  	 */
     16 -	/* class      instance    title       tags mask     isfloating   monitor */
     17 -	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
     18 -	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
     19 +	/* class      instance    title       tags mask     allowkill    isfloating   monitor */
     20 +	{ "Gimp",     NULL,       NULL,       0,            1,           1,           -1 },
     21 +	{ "Firefox",  NULL,       NULL,       1 << 8,       1,           0,           -1 },
     22  };
     23 
     24  /* layout(s) */
     25 @@ -78,6 +79,7 @@ static const Key keys[] = {
     26  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     27  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     28  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     29 +    { MODKEY,                       XK_q,      toggleallowkill,{0} },
     30  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     31  	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
     32  	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
     33 diff -up a/dwm.c b/dwm.c
     34 --- a/dwm.c	2022-10-04 19:38:18.000000000 +0200
     35 +++ b/dwm.c	2023-05-06 22:18:43.239357744 +0200
     36 @@ -93,6 +93,7 @@ struct Client {
     37  	int bw, oldbw;
     38  	unsigned int tags;
     39  	int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     40 +    int allowkill;
     41  	Client *next;
     42  	Client *snext;
     43  	Monitor *mon;
     44 @@ -137,6 +138,7 @@ typedef struct {
     45  	const char *instance;
     46  	const char *title;
     47  	unsigned int tags;
     48 +    int allowkill;
     49  	int isfloating;
     50  	int monitor;
     51  } Rule;
     52 @@ -212,6 +214,7 @@ static void tagmon(const Arg *arg);
     53  static void tile(Monitor *m);
     54  static void togglebar(const Arg *arg);
     55  static void togglefloating(const Arg *arg);
     56 +static void toggleallowkill(const Arg *arg);
     57  static void toggletag(const Arg *arg);
     58  static void toggleview(const Arg *arg);
     59  static void unfocus(Client *c, int setfocus);
     60 @@ -288,6 +291,7 @@ applyrules(Client *c)
     61  	/* rule matching */
     62  	c->isfloating = 0;
     63  	c->tags = 0;
     64 +    c->allowkill = allowkill;
     65  	XGetClassHint(dpy, c->win, &ch);
     66  	class    = ch.res_class ? ch.res_class : broken;
     67  	instance = ch.res_name  ? ch.res_name  : broken;
     68 @@ -300,6 +304,7 @@ applyrules(Client *c)
     69  		{
     70  			c->isfloating = r->isfloating;
     71  			c->tags |= r->tags;
     72 +            c->allowkill = r->allowkill;
     73  			for (m = mons; m && m->num != r->monitor; m = m->next);
     74  			if (m)
     75  				c->mon = m;
     76 @@ -1006,7 +1011,7 @@ keypress(XEvent *e)
     77  void
     78  killclient(const Arg *arg)
     79  {
     80 -	if (!selmon->sel)
     81 +	if (!selmon->sel || !selmon->sel->allowkill)
     82  		return;
     83  	if (!sendevent(selmon->sel, wmatom[WMDelete])) {
     84  		XGrabServer(dpy);
     85 @@ -1704,6 +1709,13 @@ togglebar(const Arg *arg)
     86  }
     87 
     88  void
     89 +toggleallowkill(const Arg *arg)
     90 +{
     91 +    if (!selmon->sel) return;
     92 +    selmon->sel->allowkill = !selmon->sel->allowkill;
     93 +}
     94 +
     95 +void
     96  togglefloating(const Arg *arg)
     97  {
     98  	if (!selmon->sel)