From f69b91e5480cefb531babd913022f633b2785602 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 25 Sep 2023 18:45:17 -0400 Subject: [PATCH] apply region patch --- config.def.h | 1 + dwl.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/config.def.h b/config.def.h index af29e7b..d89bdc3 100644 --- a/config.def.h +++ b/config.def.h @@ -121,6 +121,7 @@ static const Key keys[] = { { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY, XKB_KEY_b, togglebar, {0}}, + { MODKEY, XKB_KEY_r, regions, SHCMD("grim -g \"$(slurp)\"") }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, diff --git a/dwl.c b/dwl.c index 0b23c33..3898566 100644 --- a/dwl.c +++ b/dwl.c @@ -343,6 +343,7 @@ static Monitor *xytomon(double x, double y); static void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl, double *nx, double *ny); static void zoom(const Arg *arg); +static void regions(const Arg *arg); /* variables */ static const char broken[] = "broken"; @@ -3058,6 +3059,33 @@ zoom(const Arg *arg) arrange(selmon); } +void +regions(const Arg *arg) +{ + int pipefd[2]; + Client *c; + Monitor *m; + + if (pipe(pipefd) == -1) + return; + if (fork() == 0) { + close(pipefd[1]); + dup2(pipefd[0], STDIN_FILENO); + close(pipefd[0]); + setsid(); + execvp(((char **)arg->v)[0], (char **)arg->v); + die("dwl: execvp %s failed:", ((char **)arg->v)[0]); + } + + close(pipefd[0]); + wl_list_for_each(m, &mons, link) + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m)) + dprintf(pipefd[1], "%d,%d %dx%d\n", + c->geom.x, c->geom.y, c->geom.width, c->geom.height); + close(pipefd[1]); +} + #ifdef XWAYLAND void activatex11(struct wl_listener *listener, void *data)