summaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index a662911..96dc373 100644
--- a/dwl.c
+++ b/dwl.c
@@ -142,6 +142,7 @@ struct Client {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+ char scratchkey;
int isterm, noswallow;
uint32_t resize; /* configure serial of a pending resize */
pid_t pid;
@@ -249,6 +250,7 @@ typedef struct {
int isterm;
int noswallow;
int monitor;
+ const char scratchkey;
} Rule;
typedef struct {
@@ -374,6 +376,7 @@ static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
static void spawn(const Arg *arg);
+static void spawnscratch(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void swallow(Client *c, Client *toswallow);
static void tag(const Arg *arg);
@@ -386,6 +389,7 @@ static void togglefullscreen(const Arg *arg);
static void togglegaps(const Arg *arg);
static void toggleswallow(const Arg *arg);
static void toggleautoswallow(const Arg *arg);
+static void togglescratch(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -546,6 +550,8 @@ applyrules(Client *c)
const Rule *r;
Monitor *mon = selmon, *m;
+ c->scratchkey = 0;
+
appid = client_get_appid(c);
title = client_get_title(c);
@@ -555,6 +561,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->scratchkey = r->scratchkey;
newtags |= r->tags;
c->isterm = r->isterm;
c->noswallow = r->noswallow;
@@ -3086,6 +3093,16 @@ spawn(const Arg *arg)
}
}
+void spawnscratch(const Arg *arg)
+{
+ if (fork() == 0) {
+ dup2(STDERR_FILENO, STDOUT_FILENO);
+ setsid();
+ execvp(((char **)arg->v)[1], ((char **)arg->v)+1);
+ die("dwl: execvp %s failed:", ((char **)arg->v)[1]);
+ }
+}
+
void
startdrag(struct wl_listener *listener, void *data)
{
@@ -3291,6 +3308,29 @@ togglegaps(const Arg *arg)
}
void
+togglescratch(const Arg *arg)
+{
+ Client *c;
+ unsigned int found = 0;
+
+ /* search for first window that matches the scratchkey */
+ wl_list_for_each(c, &clients, link)
+ if (c->scratchkey == ((char**)arg->v)[0][0]) {
+ found = 1;
+ break;
+ }
+
+ if (found) {
+ c->tags = VISIBLEON(c, selmon) ? 0 : selmon->tagset[selmon->seltags];
+
+ focusclient(c->tags == 0 ? focustop(selmon) : c, 1);
+ arrange(selmon);
+ } else{
+ spawnscratch(arg);
+ }
+}
+
+void
toggletag(const Arg *arg)
{
uint32_t newtags;