[wiki] [sites] Update scratchpad || Gustek

From: <git_AT_suckless.org>
Date: Wed, 02 Nov 2022 01:29:56 +0100

commit 53d86ee1e7e28f3ae8fecdc0c0570c3cbb87cf72
Author: Gustek <gustek_AT_riseup.net>
Date: Wed Nov 2 01:29:42 2022 +0100

    Update scratchpad

diff --git a/dwm.suckless.org/patches/scratchpad/dwm-scratchpad-20221102-ba56fe9.diff b/dwm.suckless.org/patches/scratchpad/dwm-scratchpad-20221102-ba56fe9.diff
new file mode 100644
index 00000000..804e1124
--- /dev/null
+++ b/dwm.suckless.org/patches/scratchpad/dwm-scratchpad-20221102-ba56fe9.diff
_AT_@ -0,0 +1,92 @@
+diff --git a/config.def.h b/config.def.h
+index 9efa774..0b8b310 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -59,11 +59,14 @@ static const Layout layouts[] = {
+ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
+ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+ static const char *termcmd[] = { "st", NULL };
++static const char scratchpadname[] = "scratchpad";
++static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
+
+ static const Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
++ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+diff --git a/dwm.c b/dwm.c
+index 253aba7..4abf8d3 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -212,6 +212,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglescratch(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+_AT_@ -272,6 +273,8 @@ static Window root, wmcheckwin;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++static unsigned int scratchtag = 1 << LENGTH(tags);
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+_AT_@ -1052,6 +1055,14 @@ manage(Window w, XWindowAttributes *wa)
+ c->y = MAX(c->y, c->mon->wy);
+ c->bw = borderpx;
+
++ selmon->tagset[selmon->seltags] &= ~scratchtag;
++ if (!strcmp(c->name, scratchpadname)) {
++ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
++ c->isfloating = True;
++ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
++ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
++ }
++
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
+_AT_@ -1641,6 +1652,7 @@ spawn(const Arg *arg)
+ {
+ if (arg->v == dmenucmd)
+ dmenumon[0] = '0' + selmon->num;
++ selmon->tagset[selmon->seltags] &= ~scratchtag;
+ if (fork() == 0) {
+ if (dpy)
+ close(ConnectionNumber(dpy));
+_AT_@ -1719,6 +1731,28 @@ togglefloating(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++togglescratch(const Arg *arg)
++{
++ Client *c;
++ unsigned int found = 0;
++
++ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
++ if (found) {
++ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
++ if (newtagset) {
++ selmon->tagset[selmon->seltags] = newtagset;
++ focus(NULL);
++ arrange(selmon);
++ }
++ if (ISVISIBLE(c)) {
++ focus(c);
++ restack(selmon);
++ }
++ } else
++ spawn(arg);
++}
++
+ void
+ toggletag(const Arg *arg)
+ {
diff --git a/dwm.suckless.org/patches/scratchpad/index.md b/dwm.suckless.org/patches/scratchpad/index.md
index a0f77708..48da0567 100644
--- a/dwm.suckless.org/patches/scratchpad/index.md
+++ b/dwm.suckless.org/patches/scratchpad/index.md
_AT_@ -14,11 +14,13 @@ By default your terminal (st) is used, and the default key binding is
 
 Download
 --------
+* [dwm-scratchpad-20221102-ba56fe9.diff](dwm-scratchpad-20221102-ba56fe9.diff) - 2022-11-02
 * [dwm-scratchpad-6.2.diff](dwm-scratchpad-6.2.diff) - 2019-06-20
-* [dwm-scratchpad-20190620-cb3f58a.diff](dwm-scratchpad-20190620-cb3f58a.diff)
-* [dwm-scratchpad-20170207-bb3bd6f.diff](dwm-scratchpad-20170207-bb3bd6f.diff)
+* [dwm-scratchpad-20190620-cb3f58a.diff](dwm-scratchpad-20190620-cb3f58a.diff) - 2019-06-20
+* [dwm-scratchpad-20170207-bb3bd6f.diff](dwm-scratchpad-20170207-bb3bd6f.diff) - 2017-02-07
 
 Authors
 -------
 * Ivan J. <parazyd_AT_dyne.org>
 * Aaron D. <aaron_AT_duxler.xyz> (mechanical update to 6.2 and bugfixes)
+* Gustek M. <gustek_AT_riseup.net> (mechanical update to ba56fe9)
Received on Wed Nov 02 2022 - 01:29:56 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 02 2022 - 01:36:50 CET