aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKumar Damani <kdamani@kepler.space>2021-02-06 20:59:46 +0000
committerKumar Damani <kdamani@kepler.space>2021-02-06 20:59:46 +0000
commitd223d5b0331012ef85c067483935fa78a86ccdc7 (patch)
tree894934c373f02029063bf64f8298b0cc5b8fce36
parent40d04e1cd1a73953146268bf88a3ed23c1f1e37f (diff)
added scratchpad patch
-rw-r--r--dwm.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index dbfb321..ed86083 100644
--- a/dwm.c
+++ b/dwm.c
@@ -94,6 +94,7 @@ struct Client {
int bw, oldbw;
unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ char scratchkey;
Client *next;
Client *snext;
Monitor *mon;
@@ -146,6 +147,7 @@ typedef struct {
unsigned int tags;
int isfloating;
int monitor;
+ const char scratchkey;
} Rule;
/* function declarations */
@@ -225,11 +227,13 @@ static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
static void spawn(const Arg *arg);
+static void spawnscratch(const Arg *arg);
static void tag(const Arg *arg);
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);
@@ -320,6 +324,7 @@ applyrules(Client *c)
/* rule matching */
c->isfloating = 0;
c->tags = 0;
+ c->scratchkey = 0;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
@@ -332,6 +337,7 @@ applyrules(Client *c)
{
c->isfloating = r->isfloating;
c->tags |= r->tags;
+ c->scratchkey = r->scratchkey;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@@ -1887,6 +1893,20 @@ spawn(const Arg *arg)
}
void
+spawnscratch(const Arg *arg)
+{
+ if (fork() == 0) {
+ if (dpy)
+ close(ConnectionNumber(dpy));
+ setsid();
+ execvp(((char **)arg->v)[1], ((char **)arg->v)+1);
+ fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[1]);
+ perror(" failed");
+ exit(EXIT_SUCCESS);
+ }
+}
+
+void
tag(const Arg *arg)
{
if (selmon->sel && arg->ui & TAGMASK) {
@@ -1962,6 +1982,28 @@ togglefloating(const Arg *arg)
}
void
+togglescratch(const Arg *arg)
+{
+ Client *c;
+ unsigned int found = 0;
+
+ for (c = selmon->clients; c && !(found = c->scratchkey == ((char**)arg->v)[0][0]); c = c->next);
+ if (found) {
+ c->tags = ISVISIBLE(c) ? 0 : selmon->tagset[selmon->seltags];
+ focus(NULL);
+ arrange(selmon);
+
+ if (ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+
+ } else{
+ spawnscratch(arg);
+ }
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;