[wiki] [sites] [dwm][patch] extrabar added. Provides a second status bar supported on 6.2 || Chip Senkbeil

From: <git_AT_suckless.org>
Date: Sun, 11 Aug 2019 05:58:30 +0200

commit 7464b527743f5f4bbd15043eaf89c4509a870a18
Author: Chip Senkbeil <chip_AT_senkbeil.org>
Date: Sat Aug 10 21:23:34 2019 -0500

    [dwm][patch] extrabar added. Provides a second status bar supported on 6.2

diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2.diff b/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2.diff
new file mode 100644
index 00000000..6b87c014
--- /dev/null
+++ b/dwm.suckless.org/patches/extrabar/dwm-extrabar-6.2.diff
_AT_@ -0,0 +1,178 @@
+From 042ea1c2dc84afa9cb35d4bf2e49da05f46a6fef Mon Sep 17 00:00:00 2001
+From: Chip Senkbeil <chip.senkbeil_AT_gmail.com>
+Date: Sat, 10 Aug 2019 15:22:34 -0500
+Subject: [PATCH] Added extra bar support
+
+---
+ config.def.h | 2 +-
+ dwm.c | 64 ++++++++++++++++++++++++++++++++++++++++------------
+ 2 files changed, 51 insertions(+), 15 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..8126ef2 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -5,6 +5,7 @@ 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 char statussep = ';'; /* separator between status bars */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+_AT_@ -112,4 +113,3 @@ static Button buttons[] = {
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+ };
+-
+diff --git a/dwm.c b/dwm.c
+index 4465af1..c1117ec 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -117,6 +117,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_@ -129,6 +130,7 @@ struct Monitor {
+ Client *stack;
+ Monitor *next;
+ Window barwin;
++ Window extrabarwin;
+ const Layout *lt[2];
+ };
+
+_AT_@ -237,6 +239,7 @@ static void zoom(const Arg *arg);
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
++static char estext[256];
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
+_AT_@ -505,7 +508,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_@ -568,6 +573,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_@ -740,6 +746,12 @@ 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]);
++ drw_text(drw, 0, 0, mons->ww, bh, 0, estext, 0);
++ drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
++ }
+ }
+
+ void
+_AT_@ -1702,6 +1714,7 @@ togglebar(const Arg *arg)
+ selmon->showbar = !selmon->showbar;
+ updatebarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
++ XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh);
+ arrange(selmon);
+ }
+
+_AT_@ -1809,14 +1822,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_@ -1825,12 +1846,15 @@ updatebarpos(Monitor *m)
+ {
+ m->wy = m->my;
+ m->wh = m->mh;
++ m->wh -= bh * m->showbar * 2;
++ m->wy = m->showbar ? m->wy + bh : m->wy;
+ if (m->showbar) {
+- m->wh -= bh;
+- m->by = m->topbar ? m->wy : m->wy + m->wh;
+- m->wy = m->topbar ? m->wy + bh : m->wy;
+- } else
++ m->by = m->topbar ? m->wy - bh : m->wy + m->wh;
++ m->eby = m->topbar ? m->wy + m->wh : m->wy - bh;
++ } else {
+ m->by = -bh;
++ m->eby = -bh;
++ }
+ }
+
+ void
+_AT_@ -1987,8 +2011,20 @@ updatesizehints(Client *c)
+ void
+ updatestatus(void)
+ {
+- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
++ char text[512];
++ if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
+ strcpy(stext, "dwm-"VERSION);
++ estext[0] = '++ } else {
++ char *e = strchr(text, statussep);
++ if (e) {
++ *e = '++ strncpy(estext, e, sizeof(estext) - 1);
++ } else {
++ estext[0] = '++ }
++ strncpy(stext, text, sizeof(stext) - 1);
++ }
+ drawbar(selmon);
+ }
+
+_AT_@ -2067,7 +2103,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;
+--
+2.22.0
diff --git a/dwm.suckless.org/patches/extrabar/dwm-extrabar.png b/dwm.suckless.org/patches/extrabar/dwm-extrabar.png
new file mode 100644
index 00000000..7aa3b5f8
Binary files /dev/null and b/dwm.suckless.org/patches/extrabar/dwm-extrabar.png differ
diff --git a/dwm.suckless.org/patches/extrabar/index.md b/dwm.suckless.org/patches/extrabar/index.md
new file mode 100644
index 00000000..85355beb
--- /dev/null
+++ b/dwm.suckless.org/patches/extrabar/index.md
_AT_@ -0,0 +1,29 @@
+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.
+
+The status bar text can be set as follows:
+
+ xsetroot -name "top text;bottom text"
+
+Support for an alternative delimiter is available and the delimiter can be
+changed by editing the `statussep` variable.
+
+Download
+--------
+* [dwm-extrabar-6.2.diff](dwm-extrabar-6.2.diff) (5680b) (2019.08.10)
+
+Screenshot
+----------
+a simple extra status bar
+
+![Visual of two status bars](dwm-extrabar.png)
+
+Authors
+-------
+* Chip Senkbeil - `<chip_AT_senkbeil.org>`
Received on Sun Aug 11 2019 - 05:58:30 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 11 2019 - 06:00:30 CEST