[wiki] [sites] [dwm][patch] Add features to the extrabar patch. || Parker Wisslefield

From: <git_AT_suckless.org>
Date: Thu, 30 Sep 2021 07:53:48 +0200

commit e88121da9cf086c86b1b07b0922383726f7573fc
Author: Parker Wisslefield <git_AT_parker.wisslefield.com>
Date: Thu Sep 30 15:51:10 2021 +1000

    [dwm][patch] Add features to the extrabar patch.

diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar.png b/dwm.suckless.org/patches/extrabar/dwm-extrabar-20190810-large.png
similarity index 100%
rename from dwm.suckless.org/patches/extrabar/dwm-extrabar.png
rename to dwm.suckless.org/patches/extrabar/dwm-extrabar-20190810-large.png
diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar-20190810.png b/dwm.suckless.org/patches/extrabar/dwm-extrabar-20190810.png
new file mode 100644
index 00000000..9412b290
Binary files /dev/null and b/dwm.suckless.org/patches/extrabar/dwm-extrabar-20190810.png differ
diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar-20210930.png b/dwm.suckless.org/patches/extrabar/dwm-extrabar-20210930.png
new file mode 100644
index 00000000..8d637b5b
Binary files /dev/null and b/dwm.suckless.org/patches/extrabar/dwm-extrabar-20210930.png differ
diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2.diff b/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2-20190810.diff
similarity index 100%
rename from dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2.diff
rename to dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2-20190810.diff
diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2-20210930-a786211.diff b/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2-20210930-a786211.diff
new file mode 100644
index 00000000..ad5df021
--- /dev/null
+++ b/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2-20210930-a786211.diff
_AT_@ -0,0 +1,248 @@
+diff --git a/config.def.h b/config.def.h
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -3,8 +3,10 @@
+ /* appearance */
+ 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 topbar = 1; /* 0 means bottom bar */
++static const int showbar = 1; /* 0 means no standard bar */
++static const int topbar = 1; /* 0 means standard bar at bottom */
++static const int extrabar = 1; /* 0 means no extra bar */
++static const char statussep = ';'; /* separator between statuses */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+_AT_@ -65,6 +67,7 @@ static Key keys[] = {
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY, XK_b, togglebar, {0} },
++ { MODKEY|ShiftMask, XK_b, toggleextrabar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+ { MODKEY, XK_i, incnmaster, {.i = +1 } },
+_AT_@ -105,6 +108,9 @@ static Button buttons[] = {
+ { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button2, zoom, {0} },
+ { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
++ { ClkExBarLeftStatus, 0, Button2, spawn, {.v = termcmd } },
++ { ClkExBarMiddle, 0, Button2, spawn, {.v = termcmd } },
++ { ClkExBarRightStatus, 0, Button2, spawn, {.v = termcmd } },
+ { ClkClientWin, MODKEY, Button1, movemouse, {0} },
+ { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
+diff --git a/dwm.c b/dwm.c
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -65,6 +65,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
+ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
+ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
++ ClkExBarLeftStatus, ClkExBarMiddle, ClkExBarRightStatus,
+ ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+
+ typedef union {
+_AT_@ -117,6 +118,7 @@ struct Monitor {
+ int nmaster;
+ int num;
+ int by; /* bar geometry */
++ int eby; /* extra bar geometry */
+ int mx, my, mw, mh; /* screen size */
+ int wx, wy, ww, wh; /* window area */
+ unsigned int seltags;
+_AT_@ -124,11 +126,13 @@ struct Monitor {
+ unsigned int tagset[2];
+ int showbar;
+ int topbar;
++ int extrabar;
+ Client *clients;
+ Client *sel;
+ Client *stack;
+ Monitor *next;
+ Window barwin;
++ Window extrabarwin;
+ const Layout *lt[2];
+ };
+
+_AT_@ -211,6 +215,7 @@ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
++static void toggleextrabar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+_AT_@ -238,6 +243,8 @@ static void zoom(const Arg *arg);
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
++static char estextl[256];
++static char estextr[256];
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
+_AT_@ -444,6 +451,13 @@ buttonpress(XEvent *e)
+ click = ClkStatusText;
+ else
+ click = ClkWinTitle;
++ } else if (ev->window == selmon->extrabarwin) {
++ if (ev->x < (int)TEXTW(estextl))
++ click = ClkExBarLeftStatus;
++ else if (ev->x > selmon->ww - (int)TEXTW(estextr))
++ click = ClkExBarRightStatus;
++ else
++ click = ClkExBarMiddle;
+ } else if ((c = wintoclient(ev->window))) {
+ focus(c);
+ restack(selmon);
+_AT_@ -506,7 +520,9 @@ cleanupmon(Monitor *mon)
+ m->next = mon->next;
+ }
+ XUnmapWindow(dpy, mon->barwin);
++ XUnmapWindow(dpy, mon->extrabarwin);
+ XDestroyWindow(dpy, mon->barwin);
++ XDestroyWindow(dpy, mon->extrabarwin);
+ free(mon);
+ }
+
+_AT_@ -569,6 +585,7 @@ configurenotify(XEvent *e)
+ if (c->isfullscreen)
+ resizeclient(c, m->mx, m->my, m->mw, m->mh);
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
++ XMoveResizeWindow(dpy, m->extrabarwin, m->wx, m->eby, m->ww, bh);
+ }
+ focus(NULL);
+ arrange(NULL);
+_AT_@ -639,6 +656,7 @@ createmon(void)
+ m->nmaster = nmaster;
+ m->showbar = showbar;
+ m->topbar = topbar;
++ m->extrabar = extrabar;
+ m->lt[0] = &layouts[0];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+_AT_@ -696,7 +714,7 @@ dirtomon(int dir)
+ void
+ drawbar(Monitor *m)
+ {
+- int x, w, tw = 0;
++ int x, w, tw = 0, etwl = 0, etwr = 0;
+ int boxs = drw->fonts->h / 9;
+ int boxw = drw->fonts->h / 6 + 2;
+ unsigned int i, occ = 0, urg = 0;
+_AT_@ -741,6 +759,17 @@ drawbar(Monitor *m)
+ }
+ }
+ drw_map(drw, m->barwin, 0, 0, m->ww, bh);
++
++ if (m == selmon) { /* extra status is only drawn on selected monitor */
++ drw_setscheme(drw, scheme[SchemeNorm]);
++ /* clear default bar draw buffer by drawing a blank rectangle */
++ drw_rect(drw, 0, 0, m->ww, bh, 1, 1);
++ etwr = TEXTW(estextr) - lrpad + 2; /* 2px right padding */
++ drw_text(drw, m->ww - etwr, 0, etwr, bh, 0, estextr, 0);
++ etwl = TEXTW(estextl);
++ drw_text(drw, 0, 0, etwl, bh, 0, estextl, 0);
++ drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
++ }
+ }
+
+ void
+_AT_@ -1708,6 +1737,15 @@ togglebar(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++toggleextrabar(const Arg *arg)
++{
++ selmon->extrabar = !selmon->extrabar;
++ updatebarpos(selmon);
++ XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh);
++ arrange(selmon);
++}
++
+ void
+ togglefloating(const Arg *arg)
+ {
+_AT_@ -1812,14 +1850,22 @@ updatebars(void)
+ };
+ XClassHint ch = {"dwm", "dwm"};
+ for (m = mons; m; m = m->next) {
+- if (m->barwin)
+- continue;
+- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
+- CopyFromParent, DefaultVisual(dpy, screen),
+- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+- XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
+- XMapRaised(dpy, m->barwin);
+- XSetClassHint(dpy, m->barwin, &ch);
++ if (!m->barwin) {
++ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
++ CopyFromParent, DefaultVisual(dpy, screen),
++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
++ XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
++ XMapRaised(dpy, m->barwin);
++ XSetClassHint(dpy, m->barwin, &ch);
++ }
++ if (!m->extrabarwin) {
++ m->extrabarwin = XCreateWindow(dpy, root, m->wx, m->eby, m->ww, bh, 0, DefaultDepth(dpy, screen),
++ CopyFromParent, DefaultVisual(dpy, screen),
++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
++ XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor);
++ XMapRaised(dpy, m->extrabarwin);
++ XSetClassHint(dpy, m->extrabarwin, &ch);
++ }
+ }
+ }
+
+_AT_@ -1834,6 +1880,12 @@ updatebarpos(Monitor *m)
+ m->wy = m->topbar ? m->wy + bh : m->wy;
+ } else
+ m->by = -bh;
++ if (m->extrabar) {
++ m->wh -= bh;
++ m->eby = !m->topbar ? m->wy : m->wy + m->wh;
++ m->wy = !m->topbar ? m->wy + bh : m->wy;
++ } else
++ m->eby = -bh;
+ }
+
+ void
+_AT_@ -1990,8 +2042,26 @@ updatesizehints(Client *c)
+ void
+ updatestatus(void)
+ {
+- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
++ char text[768];
++ if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
+ strcpy(stext, "dwm-"VERSION);
++ estextl[0] = '++ estextr[0] = '++ } else {
++ char *l = strchr(text, statussep);
++ if (l) {
++ *l = '++ strncpy(estextl, l, sizeof(estextl) - 1);
++ } else
++ estextl[0] = '++ char *r = strchr(estextl, statussep);
++ if (r) {
++ *r = '++ strncpy(estextr, r, sizeof(estextr) - 1);
++ } else
++ estextr[0] = '++ strncpy(stext, text, sizeof(stext) - 1);
++ }
+ drawbar(selmon);
+ }
+
+_AT_@ -2070,7 +2140,7 @@ wintomon(Window w)
+ if (w == root && getrootptr(&x, &y))
+ return recttomon(x, y, 1, 1);
+ for (m = mons; m; m = m->next)
+- if (w == m->barwin)
++ if (w == m->barwin || w == m->extrabarwin)
+ return m;
+ if ((c = wintoclient(w)))
+ return c->mon;
diff --git a/dwm.suckless.org/patches/extrabar/index.md b/dwm.suckless.org/patches/extrabar/index.md
index 993d58b2..53c7c997 100644
--- a/dwm.suckless.org/patches/extrabar/index.md
+++ b/dwm.suckless.org/patches/extrabar/index.md
_AT_@ -3,32 +3,65 @@ extrabar
 
 Description
 -----------
-This patch will enable an extra status bar in dwm in a similar manner to the
-dualstatus patch. If the primary status is at the top via `topbar` then the
-extra status bar will be placed at the bottom and vice versa.
+This patch will enable an extra status bar in dwm, in a similar manner to the
+[dualstatus](../dualstatus/) patch. If the standard status bar is at the top
+via `topbar`, the extra status bar will be placed at the bottom and vice versa.
+
+**Since the 20210930-a786211 version**
+
+There is now support for separate left and right statuses, click functionality and toggling the extra
+bar separately from the standard bar.
+
+The statuses can be set as follows:
+
+ xsetroot -name "standard status text;extra bar left status text;extra bar right status text"
+
+If you don't want a status at the left of the extra bar, you can omit the text between the
+separators so you have `;;` between the standard status text and the right status text. You
+can change the separator by changing the `statussep` variable.
+
+There are three clicking areas on the extra bar: the left status, the middle (between the statuses)
+and the right status.
+
+You can change the visibility for the extra bar by changing the `extrabar` variable. You can
+toggle the extra bar using the `toggleextrabar` function, bound to `MODKEY+SHIFT+B`. If you
+want the bars to toggle at the same time, set them to toggle with the same keybinding.
+
+**Previous versions**
 
 The status bar text can be set as follows:
 
- xsetroot -name "top text;bottom text"
+ xsetroot -name "standard status text;extra bar status text"
 
 Support for an alternative delimiter is available and the delimiter can be
 changed by editing the `statussep` variable.
 
 The text can be anchored to the left or right side of the screen by editing
-the `extrabarright` variable (20210209 diff only.)
+the `extrabarright` variable (20210209 diff only).
+
 
 Download
 --------
-* [dwm-extrabar-6.2.diff](dwm-extrabar-6.2.diff) (5680b) (2019.08.10)
+* [dwm-extrabar-6.2-20190810.diff](dwm-extrabar-6.2-20190810.diff) (5680b) (2019.08.10)
 * [dwm-extrabar-6.2-20210209.diff](dwm-extrabar-6.2-20210209.diff) (5639b) (2021.02.09)
+* [dwm-extrabar-6.2-20210930-a786211.diff](dwm-extrabar-6.2-20210930-a786211.diff) (8817b) (2021.09.30)
+
+Screenshots
+-----------
+
+**Since the 20210930-a786211 version**
+
+![The standard and extra bars with a simple status example](dwm-extrabar-20210930.png)
+
+
+**Previous versions**
 
-Screenshot
-----------
 a simple extra status bar
 
-![Visual of two status bars](dwm-extrabar.png)
+![Visual of two status bars](dwm-extrabar-20190810.png)
 
 Authors
 -------
 * Chip Senkbeil - `<chip_AT_senkbeil.org>`
 * Finn Rayment - `<finn_AT_rayment.fr>`
+* Parker Wisslefield (20210930-a786211 version)
Received on Thu Sep 30 2021 - 07:53:48 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 30 2021 - 08:00:47 CEST