add a rule to not allow killing of clients

This commit is contained in:
speedie 2023-05-06 21:33:13 +02:00
parent 5baa811745
commit 0a9fae12a8
2 changed files with 25 additions and 21 deletions

35
rules.h
View file

@ -23,22 +23,23 @@
#define BROWSER_CLASS "chromium-bin-browser-chromium" /* This is the class for chromium-bin on Gentoo. Use xprop to find out your class. */ #define BROWSER_CLASS "chromium-bin-browser-chromium" /* This is the class for chromium-bin on Gentoo. Use xprop to find out your class. */
static const Rule rules[] = { static const Rule rules[] = {
/* class instance title tags mask isfloating ispermanent isterminal noswallow monitor unmanaged ignoretransient float x,y,w,h scratch key */ /* class instance title tags mask isfloating ispermanent isterminal noswallow allowkill monitor unmanaged ignoretransient float x,y,w,h scratch key */
{ TERMINAL_CLASS, NULL, NULL, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0 }, { TERMINAL_CLASS, NULL, NULL, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0 },
{ "Zathura", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { "Zathura", NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 },
{ "qutebrowser", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { "qutebrowser", NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 },
{ "Navigator", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { "Navigator", NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 },
{ BROWSER_CLASS, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { BROWSER_CLASS, NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 },
{ "mpv", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { "mpv", NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 },
{ "tabbed", NULL, NULL, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 }, { "tabbed", NULL, NULL, 0, 0, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ "trayer", NULL, NULL, 0, 1, 1, 0, 1, 0, 1, 0, -1, 0 }, { "trayer", NULL, NULL, 0, 1, 1, 0, 1, 1, 0, 1, 0, -1, 0 },
{ "Gsimplecal", NULL, NULL, 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { "Gsimplecal", NULL, NULL, 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "CustomizeMii 3.11 by Leathl", 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { "Musique", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 },
{ NULL, NULL, "Picture-in-Picture", 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { NULL, NULL, "CustomizeMii 3.11 by Leathl", 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "About GNU IceCat", 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { NULL, NULL, "Picture-in-Picture", 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "About LibreWolf", 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { NULL, NULL, "About GNU IceCat", 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "About Mozilla Firefox", 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { NULL, NULL, "About LibreWolf", 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "Save Image", 0, 1, 0, 0, 1, 0, 0, 0, -1, 0 }, { NULL, NULL, "About Mozilla Firefox", 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "scratchpad", 0, 0, 0, 0, 's' }, { NULL, NULL, "Save Image", 0, 1, 0, 0, 1, 1, 0, 0, 0, -1, 0 },
{ NULL, NULL, "scratchpad", 0, 0, 0, 1, 0, 's' },
}; };

View file

@ -240,7 +240,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int hintsvalid; /* https://git.suckless.org/dwm/commit/8806b6e2379372900e3d9e0bf6604bc7f727350b.html */ int hintsvalid; /* https://git.suckless.org/dwm/commit/8806b6e2379372900e3d9e0bf6604bc7f727350b.html */
int bw, oldbw; int bw, oldbw;
int cankill; int allowkill;
unsigned int tags; /* tags */ unsigned int tags; /* tags */
#if USEWINICON #if USEWINICON
unsigned int icw, ich; Picture icon; unsigned int icw, ich; Picture icon;
@ -428,6 +428,7 @@ typedef struct {
int ispermanent; int ispermanent;
int isterminal; int isterminal;
int noswallow; int noswallow;
int allowkill;
int monitor; int monitor;
int unmanaged; int unmanaged;
int ignoretransient; int ignoretransient;
@ -1072,6 +1073,7 @@ applyrules(Client *c)
c->isfloating = 0; c->isfloating = 0;
c->tags = 0; c->tags = 0;
c->scratchkey = 0; c->scratchkey = 0;
c->allowkill = allowkill;
XGetClassHint(dpy, c->win, &ch); XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : notitle; class = ch.res_class ? ch.res_class : notitle;
instance = ch.res_name ? ch.res_name : notitle; instance = ch.res_name ? ch.res_name : notitle;
@ -1091,6 +1093,7 @@ applyrules(Client *c)
c->ignoretransient = r->ignoretransient; c->ignoretransient = r->ignoretransient;
c->ispermanent = r->ispermanent; c->ispermanent = r->ispermanent;
c->tags |= r->tags; c->tags |= r->tags;
c->allowkill = r->allowkill;
unmanaged = r->unmanaged; unmanaged = r->unmanaged;
c->scratchkey = r->scratchkey; c->scratchkey = r->scratchkey;
if (r->isfloating) { if (r->isfloating) {
@ -3257,7 +3260,7 @@ incrogaps(const Arg *arg)
void void
killclient(const Arg *arg) killclient(const Arg *arg)
{ {
if (!selmon->sel || selmon->sel->ispermanent || !selmon->sel->cankill) if (!selmon->sel || selmon->sel->ispermanent || !selmon->sel->allowkill)
return; return;
#if USESYSTRAY #if USESYSTRAY
if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) { if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) {
@ -3326,7 +3329,7 @@ manage(Window w, XWindowAttributes *wa)
c->h = c->oldh = wa->height; c->h = c->oldh = wa->height;
c->oldbw = wa->border_width; c->oldbw = wa->border_width;
c->cfact = 1.0; c->cfact = 1.0;
c->cankill = allowkill; /* we can kill by default */ c->allowkill = c->allowkill; /* we can kill by default */
#if USEWINICON #if USEWINICON
updateicon(c); updateicon(c);
@ -5618,7 +5621,7 @@ toggleakill(const Arg *arg)
if (!selmon->sel) if (!selmon->sel)
return; return;
selmon->sel->cankill = !selmon->sel->cankill; selmon->sel->allowkill = !selmon->sel->allowkill;
} }
void void