dwm-spawntag-6.2.diff (2783B)
1 From abace8a090f579a9bd2513e78e0ebe9d9fa1e0bb Mon Sep 17 00:00:00 2001 2 From: Piyush Pangtey <gokuvsvegita@gmail.com> 3 Date: Wed, 19 May 2021 19:27:34 +0530 4 Subject: [PATCH] [Feature] spawntag 5 6 spawn application whenever a tag is middle clicked 7 --- 8 config.def.h | 16 ++++++++++++++++ 9 dwm.c | 14 ++++++++++++++ 10 2 files changed, 30 insertions(+) 11 12 diff --git a/config.def.h b/config.def.h 13 index 1c0b587..442b556 100644 14 --- a/config.def.h 15 +++ b/config.def.h 16 @@ -54,11 +54,26 @@ static const Layout layouts[] = { 17 /* helper for spawning shell commands in the pre dwm-5.0 fashion */ 18 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } 19 20 +/* helper for launching gtk application */ 21 +#define GTKCMD(cmd) { .v = (const char*[]){ "/usr/bin/gtk-launch", cmd, NULL } } 22 + 23 /* commands */ 24 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ 25 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; 26 static const char *termcmd[] = { "st", NULL }; 27 28 +static const Arg tagexec[] = { 29 + { .v = termcmd }, 30 + { .v = termcmd }, 31 + { .v = termcmd }, 32 + { .v = termcmd }, 33 + { .v = termcmd }, 34 + { .v = termcmd }, 35 + { .v = termcmd }, 36 + { .v = termcmd }, 37 + { .v = termcmd } 38 +}; 39 + 40 static Key keys[] = { 41 /* modifier key function argument */ 42 { MODKEY, XK_p, spawn, {.v = dmenucmd } }, 43 @@ -108,6 +123,7 @@ static Button buttons[] = { 44 { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, 45 { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, 46 { ClkTagBar, 0, Button1, view, {0} }, 47 + { ClkTagBar, 0, Button2, spawntag, {0} }, 48 { ClkTagBar, 0, Button3, toggleview, {0} }, 49 { ClkTagBar, MODKEY, Button1, tag, {0} }, 50 { ClkTagBar, MODKEY, Button3, toggletag, {0} }, 51 diff --git a/dwm.c b/dwm.c 52 index 4465af1..89b3220 100644 53 --- a/dwm.c 54 +++ b/dwm.c 55 @@ -207,6 +207,7 @@ static void showhide(Client *c); 56 static void sigchld(int unused); 57 static void spawn(const Arg *arg); 58 static void tag(const Arg *arg); 59 +static void spawntag(const Arg *arg); 60 static void tagmon(const Arg *arg); 61 static void tile(Monitor *); 62 static void togglebar(const Arg *arg); 63 @@ -1662,6 +1663,19 @@ tag(const Arg *arg) 64 } 65 } 66 67 +void 68 +spawntag(const Arg *arg) 69 +{ 70 + if (arg->ui & TAGMASK) { 71 + for (int i = LENGTH(tags); i >= 0; i--) { 72 + if (arg->ui & 1<<i) { 73 + spawn(&tagexec[i]); 74 + return; 75 + } 76 + } 77 + } 78 +} 79 + 80 void 81 tagmon(const Arg *arg) 82 { 83 -- 84 2.31.1 85