diff options
author | Joe <rbo@gmx.us> | 2025-03-01 23:31:55 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2025-03-01 23:31:55 +0100 |
commit | df7c5a9eb465cc393f26ece674f6971a6d2b1cc0 (patch) | |
tree | f2ba5283f3e3eb090b16d8e20710fcecd93102d7 /dwl.c | |
parent | shifted (diff) | |
download | dwl-df7c5a9eb465cc393f26ece674f6971a6d2b1cc0.tar.gz dwl-df7c5a9eb465cc393f26ece674f6971a6d2b1cc0.tar.bz2 dwl-df7c5a9eb465cc393f26ece674f6971a6d2b1cc0.tar.xz dwl-df7c5a9eb465cc393f26ece674f6971a6d2b1cc0.tar.zst dwl-df7c5a9eb465cc393f26ece674f6971a6d2b1cc0.zip |
scratchpads yey
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -151,6 +151,7 @@ struct Client { unsigned int bw; uint32_t tags; int isfloating, isurgent, isfullscreen, isterm, noswallow; + char scratchkey; uint32_t resize; /* configure serial of a pending resize */ pid_t pid; Client *swallowing, *swallowedby; @@ -269,6 +270,7 @@ typedef struct { int isterm; int noswallow; int monitor; + const char scratchkey; } Rule; typedef struct { @@ -386,6 +388,7 @@ static void setup(void); static void shiftboth(const Arg *arg); static void shiftview(const Arg *arg); static void spawn(const Arg *arg); +static void spawnscratch(const Arg *arg); static void startdrag(struct wl_listener *listener, void *data); static int statusin(int fd, unsigned int mask, void *data); static void tag(const Arg *arg); @@ -395,6 +398,7 @@ static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void togglefullscreen(const Arg *arg); static void togglegaps(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); @@ -542,6 +546,7 @@ applyrules(Client *c) Monitor *mon = selmon, *m; c->isfloating = client_is_float_type(c); + c->scratchkey = 0; if (!(appid = client_get_appid(c))) appid = broken; if (!(title = client_get_title(c))) @@ -555,6 +560,7 @@ applyrules(Client *c) c->isfloating = r->isfloating; c->isterm = r->isterm; c->noswallow = r->noswallow; + c->scratchkey = r->scratchkey; newtags |= r->tags; i = 0; wl_list_for_each(m, &mons, link) { @@ -3113,6 +3119,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) { @@ -3237,6 +3253,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; |