From abace8a090f579a9bd2513e78e0ebe9d9fa1e0bb Mon Sep 17 00:00:00 2001 From: Piyush Pangtey Date: Wed, 19 May 2021 19:27:34 +0530 Subject: [PATCH] [Feature] spawntag spawn application whenever a tag is middle clicked --- config.def.h | 16 ++++++++++++++++ dwm.c | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/config.def.h b/config.def.h index 1c0b587..442b556 100644 --- a/config.def.h +++ b/config.def.h @@ -54,11 +54,26 @@ static const Layout layouts[] = { /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } +/* helper for launching gtk application */ +#define GTKCMD(cmd) { .v = (const char*[]){ "/usr/bin/gtk-launch", cmd, NULL } } + /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +static const Arg tagexec[] = { + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd }, + { .v = termcmd } +}; + static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, @@ -108,6 +123,7 @@ static Button buttons[] = { { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button2, spawntag, {0} }, { ClkTagBar, 0, Button3, toggleview, {0} }, { ClkTagBar, MODKEY, Button1, tag, {0} }, { ClkTagBar, MODKEY, Button3, toggletag, {0} }, diff --git a/dwm.c b/dwm.c index 4465af1..89b3220 100644 --- a/dwm.c +++ b/dwm.c @@ -207,6 +207,7 @@ static void showhide(Client *c); static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); +static void spawntag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *); static void togglebar(const Arg *arg); @@ -1662,6 +1663,19 @@ tag(const Arg *arg) } } +void +spawntag(const Arg *arg) +{ + if (arg->ui & TAGMASK) { + for (int i = LENGTH(tags); i >= 0; i--) { + if (arg->ui & 1<