1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# From abace8a090f579a9bd2513e78e0ebe9d9fa1e0bb Mon Sep 17 00:00:00 2001
# From: Piyush Pangtey <gokuvsvegita@gmail.com>
# 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<<i) {
+ spawn(&tagexec[i]);
+ return;
+ }
+ }
+ }
+}
+
void
tagmon(const Arg *arg)
{
--
2.31.1
|