diff options
| -rw-r--r-- | dwm.c | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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; |
