summaryrefslogtreecommitdiff
path: root/dwm/patches/dwm-bartoggle-keybinds-6.4.diff
blob: d06bedf905516af6b8e95ca9a55258f26549452d (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# This patch adds keybinds to toggle each part of the dwm bar. This include the title, tags, layout indicator, status and floating indicator.
# It also allows you to show/hide parts by default, similar to showbar.
#
# There is also a version without keybinds if you don't want keybinds, see the dwm-bartoggle-6.4.diff patch.

diff -up a/config.def.h b/config.def.h
--- a/config.def.h	2022-10-04 19:38:18.000000000 +0200
+++ b/config.def.h	2022-10-22 14:40:36.113933644 +0200
@@ -4,6 +4,11 @@
 static const unsigned int borderpx  = 1;        /* border pixel of windows */
 static const unsigned int snap      = 32;       /* snap pixel */
 static const int showbar            = 1;        /* 0 means no bar */
+static const int showtitle          = 1;        /* 0 means no title */
+static const int showtags           = 1;        /* 0 means no tags */
+static const int showlayout         = 1;        /* 0 means no layout indicator */
+static const int showstatus         = 1;        /* 0 means no status bar */
+static const int showfloating       = 1;        /* 0 means no floating indicator */
 static const int topbar             = 1;        /* 0 means bottom bar */
 static const char *fonts[]          = { "monospace:size=10" };
 static const char dmenufont[]       = "monospace:size=10";
@@ -78,6 +83,11 @@ static const Key keys[] = {
 	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
 	{ MODKEY,                       XK_space,  setlayout,      {0} },
 	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
+	{ MODKEY,					    XK_t,      togglebartitle, {0} },
+	{ MODKEY,                       XK_s,      togglebarstatus,{0} },
+	{ MODKEY|ShiftMask,             XK_t,      togglebartags,  {0} },
+	{ MODKEY|ShiftMask,				XK_s,      togglebarlt,    {0} },
+	{ MODKEY|ShiftMask,				XK_f,      togglebarfloat, {0} },
 	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
 	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
 	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
diff -up a/dwm.c b/dwm.c
--- a/dwm.c	2022-10-04 19:38:18.000000000 +0200
+++ b/dwm.c	2022-10-22 14:41:29.903932288 +0200
@@ -123,6 +123,11 @@ struct Monitor {
 	unsigned int sellt;
 	unsigned int tagset[2];
 	int showbar;
+	int showtitle;
+	int showtags;
+	int showlayout;
+	int showstatus;
+	int showfloating;
 	int topbar;
 	Client *clients;
 	Client *sel;
@@ -211,6 +216,11 @@ static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static void tile(Monitor *m);
 static void togglebar(const Arg *arg);
+static void togglebartags(const Arg *arg);
+static void togglebartitle(const Arg *arg);
+static void togglebarlt(const Arg *arg);
+static void togglebarstatus(const Arg *arg);
+static void togglebarfloat(const Arg *arg);
 static void togglefloating(const Arg *arg);
 static void toggletag(const Arg *arg);
 static void toggleview(const Arg *arg);
@@ -435,16 +445,17 @@ buttonpress(XEvent *e)
 	if (ev->window == selmon->barwin) {
 		i = x = 0;
 		do
-			x += TEXTW(tags[i]);
+		    if (selmon->showtags)
+				x += TEXTW(tags[i]);
 		while (ev->x >= x && ++i < LENGTH(tags));
-		if (i < LENGTH(tags)) {
+		if (i < LENGTH(tags) && selmon->showtags) {
 			click = ClkTagBar;
 			arg.ui = 1 << i;
-		} else if (ev->x < x + TEXTW(selmon->ltsymbol))
+		} else if (ev->x < x + TEXTW(selmon->ltsymbol) && selmon->showlayout)
 			click = ClkLtSymbol;
-		else if (ev->x > selmon->ww - (int)TEXTW(stext))
+		else if (ev->x > selmon->ww - (int)TEXTW(stext) && selmon->showstatus)
 			click = ClkStatusText;
-		else
+		else if (selmon->showtitle)
 			click = ClkWinTitle;
 	} else if ((c = wintoclient(ev->window))) {
 		focus(c);
@@ -641,6 +652,11 @@ createmon(void)
 	m->mfact = mfact;
 	m->nmaster = nmaster;
 	m->showbar = showbar;
+	m->showtitle = showtitle;
+	m->showtags = showtags;
+	m->showlayout = showlayout;
+	m->showstatus = showstatus;
+	m->showfloating = showfloating;
 	m->topbar = topbar;
 	m->lt[0] = &layouts[0];
 	m->lt[1] = &layouts[1 % LENGTH(layouts)];
@@ -709,7 +725,7 @@ drawbar(Monitor *m)
 		return;

 	/* draw status first so it can be overdrawn by tags later */
-	if (m == selmon) { /* status is only drawn on selected monitor */
+	if (m == selmon && selmon->showstatus) { /* status is only drawn on selected monitor */
 		drw_setscheme(drw, scheme[SchemeNorm]);
 		tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
 		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
@@ -717,29 +733,35 @@ drawbar(Monitor *m)

 	for (c = m->clients; c; c = c->next) {
 		occ |= c->tags;
-		if (c->isurgent)
+		if (c->isurgent && selmon->showtags)
 			urg |= c->tags;
 	}
 	x = 0;
 	for (i = 0; i < LENGTH(tags); i++) {
-		w = TEXTW(tags[i]);
-		drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
-		drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
-		if (occ & 1 << i)
-			drw_rect(drw, x + boxs, boxs, boxw, boxw,
-				m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
-				urg & 1 << i);
-		x += w;
-	}
-	w = TEXTW(m->ltsymbol);
-	drw_setscheme(drw, scheme[SchemeNorm]);
-	x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
+		if (selmon->showtags) {
+				w = TEXTW(tags[i]);
+				drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+				drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+				if (occ & 1 << i && selmon->showfloating)
+				drw_rect(drw, x + boxs, boxs, boxw, boxw,
+						m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+						urg & 1 << i);
+				x += w;
+		}
+    }
+
+	/* draw layout indicator if selmon->showlayout */
+	if (selmon->showlayout) {
+		w = TEXTW(m->ltsymbol);
+		drw_setscheme(drw, scheme[SchemeNorm]);
+		x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
+	}

 	if ((w = m->ww - tw - x) > bh) {
-		if (m->sel) {
+		if (m->sel && selmon->showtitle) {
 			drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
 			drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
-			if (m->sel->isfloating)
+			if (m->sel->isfloating && selmon->showfloating)
 				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
 		} else {
 			drw_setscheme(drw, scheme[SchemeNorm]);
@@ -1238,7 +1260,7 @@ propertynotify(XEvent *e)
 		}
 		if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
 			updatetitle(c);
-			if (c == c->mon->sel)
+			if (c == c->mon->sel && selmon->showtitle)
 				drawbar(c->mon);
 		}
 		if (ev->atom == netatom[NetWMWindowType])
@@ -1704,6 +1726,41 @@ togglebar(const Arg *arg)
 }

 void
+togglebartags(const Arg *arg)
+{
+    selmon->showtags = !selmon->showtags;
+	arrange(selmon);
+}
+
+void
+togglebartitle(const Arg *arg)
+{
+    selmon->showtitle = !selmon->showtitle;
+	arrange(selmon);
+}
+
+void
+togglebarlt(const Arg *arg)
+{
+    selmon->showlayout = !selmon->showlayout;
+	arrange(selmon);
+}
+
+void
+togglebarstatus(const Arg *arg)
+{
+    selmon->showstatus = !selmon->showstatus;
+	arrange(selmon);
+}
+
+void
+togglebarfloat(const Arg *arg)
+{
+    selmon->showfloating = !selmon->showfloating;
+	arrange(selmon);
+}
+
+void
 togglefloating(const Arg *arg)
 {
 	if (!selmon->sel)
@@ -1987,7 +2044,7 @@ updatesizehints(Client *c)
 void
 updatestatus(void)
 {
-	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
+	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)) && selmon->showstatus)
 		strcpy(stext, "dwm-"VERSION);
 	drawbar(selmon);
 }