[wiki] [sites] Add two patches, bartoggle and bartoggle with keybinds. || speediegq

From: <git_AT_suckless.org>
Date: Sat, 22 Oct 2022 15:25:03 +0200

commit 8bcd7171cba3e175d653a9f7dc58f9bf7ebf1643
Author: speediegq <speedie.alt_AT_gmail.com>
Date: Sat Oct 22 15:15:36 2022 +0200

    Add two patches, bartoggle and bartoggle with keybinds.
    
    Bartoggle allows you to show and hide every part of the bar (with
    keybinds in the case of the keybinds version).

diff --git a/dwm.suckless.org/patches/bartoggle/dwm-bartoggle-6.4.diff b/dwm.suckless.org/patches/bartoggle/dwm-bartoggle-6.4.diff
new file mode 100644
index 00000000..dd67a84c
--- /dev/null
+++ b/dwm.suckless.org/patches/bartoggle/dwm-bartoggle-6.4.diff
_AT_@ -0,0 +1,124 @@
+This patch is relatively simple. It adds 5 more options that allow you to choose whether or not to show or hide each part of the bar.
+NOTE: It does not include include keybinds, see the dwm-bartoggle-keybinds-6.4.diff version for that.
+
+To use, simply patch this in and change the options this patch adds to your liking!
+
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2022-10-21 15:49:56.390287336 +0200
++++ b/config.def.h 2022-10-21 16:38:50.766276143 +0200
+_AT_@ -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";
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2022-10-21 15:49:56.391287336 +0200
++++ b/dwm.c 2022-10-21 16:42:16.509275358 +0200
+_AT_@ -435,16 +435,17 @@ buttonpress(XEvent *e)
+ if (ev->window == selmon->barwin) {
+ i = x = 0;
+ do
+- x += TEXTW(tags[i]);
++ if (showtags)
++ x += TEXTW(tags[i]);
+ while (ev->x >= x && ++i < LENGTH(tags));
+- if (i < LENGTH(tags)) {
++ if (i < LENGTH(tags) && showtags) {
+ click = ClkTagBar;
+ arg.ui = 1 << i;
+- } else if (ev->x < x + TEXTW(selmon->ltsymbol))
++ } else if (ev->x < x + TEXTW(selmon->ltsymbol) && showlayout)
+ click = ClkLtSymbol;
+- else if (ev->x > selmon->ww - (int)TEXTW(stext))
++ else if (ev->x > selmon->ww - (int)TEXTW(stext) && showstatus)
+ click = ClkStatusText;
+- else
++ else if (showtitle)
+ click = ClkWinTitle;
+ } else if ((c = wintoclient(ev->window))) {
+ focus(c);
+_AT_@ -709,7 +710,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 && 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);
+_AT_@ -717,29 +718,35 @@ drawbar(Monitor *m)
+
+ for (c = m->clients; c; c = c->next) {
+ occ |= c->tags;
+- if (c->isurgent)
++ if (c->isurgent && 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 (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 && 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 showlayout */
++ if (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 && 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 && showfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+ } else {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+_AT_@ -1238,7 +1245,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 && showtitle)
+ drawbar(c->mon);
+ }
+ if (ev->atom == netatom[NetWMWindowType])
+_AT_@ -1987,7 +1994,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)) && showstatus)
+ strcpy(stext, "dwm-"VERSION);
+ drawbar(selmon);
+ }
diff --git a/dwm.suckless.org/patches/bartoggle/dwm-bartoggle-keybinds-6.4.diff b/dwm.suckless.org/patches/bartoggle/dwm-bartoggle-keybinds-6.4.diff
new file mode 100644
index 00000000..07d0b714
--- /dev/null
+++ b/dwm.suckless.org/patches/bartoggle/dwm-bartoggle-keybinds-6.4.diff
_AT_@ -0,0 +1,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
+_AT_@ -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";
+_AT_@ -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
+_AT_@ -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;
+_AT_@ -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);
+_AT_@ -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);
+_AT_@ -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)];
+_AT_@ -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);
+_AT_@ -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]);
+_AT_@ -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])
+_AT_@ -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)
+_AT_@ -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);
+ }
diff --git a/dwm.suckless.org/patches/bartoggle/index.md b/dwm.suckless.org/patches/bartoggle/index.md
new file mode 100644
index 00000000..20bbf23f
--- /dev/null
+++ b/dwm.suckless.org/patches/bartoggle/index.md
_AT_@ -0,0 +1,23 @@
+bartoggle
+=========
+
+Description
+-----------
+This patch allows you to toggle every part of the dwm bar with keybinds. In addition to showbar, this patch adds:
+
+* `showtitle` - Whether or not to show the title
+* `showtags` - Whether or not to show the tags
+* `showlayout` - Whether or not to show the layout indicator
+* `showstatus` - Whether or not to show the status bar
+* `showfloating` - Whether or not to show the floating indicator
+
+If you opt for the keybinds version, it also adds keybinds that can be used to toggle these options during runtime. This patch is maintained on its codeberg repository [here](https://codeberg.org/speedie/patches).
+
+Download
+--------
+* [dwm-bartoggle-6.4.diff](dwm-bartoggle-6.4.diff)
+* [dwm-bartoggle-keybinds-6.4.diff](dwm-bartoggle-keybinds-6.4.diff)
+
+Author
+------
+* speedie <speedie_AT_duck.com>
Received on Sat Oct 22 2022 - 15:25:03 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 22 2022 - 15:36:49 CEST