aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README1
-rw-r--r--config.h3
-rw-r--r--dwm.c34
3 files changed, 38 insertions, 0 deletions
diff --git a/README b/README
index 92bb94f..b6eec2f 100644
--- a/README
+++ b/README
@@ -53,3 +53,4 @@ Shiftview - https://lists.suckless.org/dev/1104/7590.html
noborder - https://dwm.suckless.org/patches/noborder/
pertag - https://dwm.suckless.org/patches/pertag/
attachaside - https://dwm.suckless.org/patches/attachaside/
+scratchpad - https://dwm.suckless.org/patches/scratchpad/
diff --git a/config.h b/config.h
index 08d2112..923313f 100644
--- a/config.h
+++ b/config.h
@@ -57,6 +57,8 @@ 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_gray2, "-sf", col_gray3, NULL };
static const char *termcmd[] = { "urxvt", NULL };
+static const char scratchpadname[] = "scratchpad";
+static const char *scratchpadcmd[] = { "urxvt", "-title", scratchpadname, "-g", "127x43", NULL };
static Key keys[] = {
/* modifier key function argument */
@@ -96,6 +98,7 @@ static Key keys[] = {
{ MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_a, shiftview, {.i = -1} },
{ MODKEY, XK_d, shiftview, {.i = +1} },
+ { MODKEY, XK_minus, togglescratch, {.v = scratchpadcmd } },
};
/* button definitions */
diff --git a/dwm.c b/dwm.c
index cb4428b..b6c2f26 100644
--- a/dwm.c
+++ b/dwm.c
@@ -216,6 +216,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *);
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);
@@ -286,6 +287,8 @@ struct Pertag {
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
};
+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]; };
@@ -1090,6 +1093,14 @@ manage(Window w, XWindowAttributes *wa)
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
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);
@@ -1699,6 +1710,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));
@@ -1778,6 +1790,28 @@ togglefloating(const Arg *arg)
}
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)
{
unsigned int newtags;