[wiki] [sites] New patch:This patch allows users to easily use other bars with dwm. || dadaurs

From: <git_AT_suckless.org>
Date: Mon, 18 May 2020 21:52:18 +0200

commit 0d97f4da5be950d1d206b1594da6c226edc26b76
Author: dadaurs <david.wiedemann_AT_outlook.com>
Date: Mon May 18 21:48:25 2020 +0200

    New patch:This patch allows users to easily use other bars with dwm.

diff --git a/dwm.suckless.org/patches/script_tags/dwm-script_tags-6.2.diff b/dwm.suckless.org/patches/script_tags/dwm-script_tags-6.2.diff
new file mode 100644
index 00000000..7cf07cbf
--- /dev/null
+++ b/dwm.suckless.org/patches/script_tags/dwm-script_tags-6.2.diff
_AT_@ -0,0 +1,121 @@
+diff -up dwmdiff/dwm-6.2/config.def.h dwm-6.2/config.def.h
+--- dwmdiff/dwm-6.2/config.def.h 2019-02-02 13:55:28.000000000 +0100
++++ dwm-6.2/config.def.h 2020-05-18 20:27:30.392698992 +0200
+_AT_@ -3,6 +3,9 @@
+ /* appearance */
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
++static const char *tagfile = "/tmp/dwm_workspaces";
++static const int barheight = 25; /* 0 means bottom bar */
++static const char *sepchar = ":";
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
+ static const char *fonts[] = { "monospace:size=10" };
+Only in dwm-6.2: config.h
+Only in dwm-6.2: drw.o
+Only in dwm-6.2: dwm
+diff -up dwmdiff/dwm-6.2/dwm.c dwm-6.2/dwm.c
+--- dwmdiff/dwm-6.2/dwm.c 2019-02-02 13:55:28.000000000 +0100
++++ dwm-6.2/dwm.c 2020-05-18 20:26:52.791699537 +0200
+_AT_@ -695,51 +695,34 @@ dirtomon(int dir)
+ void
+ drawbar(Monitor *m)
+ {
+- int x, w, sw = 0;
+- int boxs = drw->fonts->h / 9;
+- int boxw = drw->fonts->h / 6 + 2;
+ unsigned int i, occ = 0, urg = 0;
++ FILE *fd;
+ Client *c;
+
+- /* draw status first so it can be overdrawn by tags later */
+- if (m == selmon) { /* status is only drawn on selected monitor */
+- drw_setscheme(drw, scheme[SchemeNorm]);
+- sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
+- }
++ fd = fopen(tagfile,"w+");
+
+ for (c = m->clients; c; c = c->next) {
+ occ |= c->tags;
+ if (c->isurgent)
+ 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 = blw = 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 - sw - x) > bh) {
+- if (m->sel) {
+- 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)
+- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+- } else {
+- drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_rect(drw, x, 0, w, bh, 1, 1);
+- }
+- }
+- drw_map(drw, m->barwin, 0, 0, m->ww, bh);
++ fprintf(fd,"%s",sepchar);
++ if ( occ & 1 << i && m->tagset[m->seltags] & 1 << i ) {
++ fprintf(fd,"O%s",tags[i]);
++ } else if ( !( occ & 1 << i )&& m->tagset[m->seltags] & 1 << i ) {
++ fprintf(fd,"E%s",tags[i]);
++ } else if ( occ & 1 << i && !( m->tagset[m->seltags] & 1 << i ) ) {
++ fprintf(fd,"o%s",tags[i]);
++ } else
++ fprintf(fd,"e%s",tags[i]);
++
++ /*x += w;*/
++ }
++ fprintf(fd,"%s",sepchar);
++ fprintf(fd,"%s",m->ltsymbol);
++ fprintf(fd,"
");
++ fclose(fd);
+ }
+
+ void
+_AT_@ -1545,7 +1528,7 @@ setup(void)
+ if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
+ lrpad = drw->fonts->h;
+- bh = drw->fonts->h + 2;
++ bh = barheight;
+ updategeom();
+ /* init atoms */
+ utf8string = XInternAtom(dpy, "UTF8_STRING", False);
+_AT_@ -1802,18 +1785,10 @@ void
+ updatebars(void)
+ {
+ Monitor *m;
+- XSetWindowAttributes wa = {
+- .override_redirect = True,
+- .background_pixmap = ParentRelative,
+- .event_mask = ButtonPressMask|ExposureMask
+- };
+ 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);
+Only in dwm-6.2: dwm.o
+Only in dwm-6.2: dwm-script_tags-6.2.diff
+Only in dwm-6.2: test.diff
+Only in dwm-6.2: util.o
diff --git a/dwm.suckless.org/patches/script_tags/index.md b/dwm.suckless.org/patches/script_tags/index.md
new file mode 100644
index 00000000..d0704974
--- /dev/null
+++ b/dwm.suckless.org/patches/script_tags/index.md
_AT_@ -0,0 +1,46 @@
+script_tags
+=====================
+
+Description
+-----------
+This patch does two things:
+1) It removes the code that generates the bar, but still leaves a "toggleable" area.
+2) On X events, it writes all the tag and layout information to a user defined file.
+
+This allows any bar that reads stdin to be used in conjuction with dwm.
+
+The patch introduces 3 variables:
+barheight: sets the size of the top gap in pixels(this gap remains toggleable with the togglebar function).
+sepchar: sets the character used to delimitate different workspaces(see below).
+tagfile: sets the path of the file to wich the tag and layout information is written to.
+
+The tagfile uses an easy syntax.
+Each tagname is prefixed with a character discribing the state of that tag.
+There are 4 different states:
+
+state 'e': tag is empty and not focused
+
+state 'E': tag is empty and focused
+
+state 'o': tag is occupied and not focused
+
+state 'O': tag is occupied and focused
+
+The different tags with respective tag information are separated by the sepchar variable defined in config.h.
+
+A simple example would be:
+```
+echo /tmp/dwm_workspaces| entr cat /tmp/dwm_workspaces | lemonbar
+```
+
+Download
+-----------
+*[dwm-script_tags-6.2.diff](dwm-script_tags-6.2.diff) (18.05.2020)
+
+Authors
+-----------
+* David Wiedemann <david.wiedemann2[at]gmail.com>
+
+
+
+
Received on Mon May 18 2020 - 21:52:18 CEST

This archive was generated by hypermail 2.3.0 : Mon May 18 2020 - 22:00:49 CEST